Skip to content

Commit

Permalink
Merge pull request #4 from jonasdekeukelaere/creating-clients
Browse files Browse the repository at this point in the history
Allow for creating clients with just company and vat
  • Loading branch information
jonasdekeukelaere authored Aug 5, 2024
2 parents f130392 + 5f02b55 commit edc012d
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

namespace SumoCoders\DeFactuur\Client;

use InvalidArgumentException;

class Client
{
// required
protected string $lastName;
protected ?string $lastName;

protected array $email;

Expand Down Expand Up @@ -47,11 +49,21 @@ class Client
protected ?bool $disabled;

public function __construct(
string $lastName,
array $email,
Address $billingAddress,
Address $companyAddress
Address $companyAddress,
?string $lastName = null,
?string $company = null,
?string $vat = null
) {
if ($lastName === null && $company === null) {
throw new InvalidArgumentException('You need to provide either a last name or a company name');
}

if ($company && !$vat) {
throw new InvalidArgumentException('You need to provide a VAT number when providing a company name');
}

$this->lastName = $lastName;
$this->email = $email;
$this->billingAddress = $billingAddress;
Expand All @@ -61,8 +73,8 @@ public function __construct(
$this->paymentDays = null;
$this->replacedById = null;
$this->cid = null;
$this->company = null;
$this->vat = null;
$this->company = $company;
$this->vat = $vat;
$this->firstName = null;
$this->phone = null;
$this->fax = null;
Expand Down Expand Up @@ -231,7 +243,7 @@ public function setLastName(string $lastName): Client
return $this;
}

public function getLastName(): string
public function getLastName(): ?string
{
return $this->lastName;
}
Expand Down

0 comments on commit edc012d

Please sign in to comment.