small fixes

Signed-off-by: Maurice Preuß (envoyr) <hello@envoyr.com>
This commit is contained in:
2025-04-30 06:43:07 +02:00
parent 5b2b3c72cc
commit 71663bffd8
9 changed files with 63 additions and 12 deletions

View File

@@ -6,12 +6,34 @@ use stdClass;
trait MagicProperties
{
protected function setMagicProperties(stdClass $data): void
protected function setMagicProperties(stdClass|array $data): void
{
foreach ($data as $key => $value) {
foreach ((object)$data as $key => $value) {
if (!property_exists($this, $key)) {
$this->{$key} = $value;
}
}
}
/**
* Magic getter: return null for undefined properties
*
* @param string $name
* @return mixed|null
*/
public function __get(string $name)
{
return null;
}
/**
* Magic isset: return false for undefined properties
*
* @param string $name
* @return bool
*/
public function __isset(string $name): bool
{
return false;
}
}

View File

@@ -17,9 +17,9 @@ trait ManagesInvoices
* @throws RequestRequiresClientIdException
* @throws GuzzleException
*/
public function invoices(): Invoices
public function invoices(array $parameters = []): Invoices
{
return (new Invoices($this->request('GET', 'v1/invoices')))
return (new Invoices($this->request('GET', 'v1/invoices', [], $parameters)))
->setBillable($this);
}
}

View File

@@ -18,9 +18,9 @@ trait ManagesOrders
* @throws RequestRequiresClientIdException
* @throws GuzzleException
*/
public function orders(): Orders
public function orders(array $parameters = []): Orders
{
return (new Orders($this->request('GET', 'v1/orders')))
return (new Orders($this->request('GET', 'v1/orders', [], $parameters)))
->setBillable($this);
}
}