Skip to content

Commit

Permalink
Merge branch '2.x' of https://github.com/Tactics/FodAttest28186 into 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
TacticsJan committed Feb 17, 2023
2 parents c5d900e + 3d1b921 commit f4ab9ef
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Exception/EmptyFamilyNameException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Tactics\FodAttest28186\Exception;

use Exception;
use Throwable;

final class EmptyFamilyNameException extends Exception
{
public function __construct($message = "", Throwable $previous = null)
{
parent::__construct($message, 0, $previous);
}
}
14 changes: 14 additions & 0 deletions src/Exception/EmptyGivenNameException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Tactics\FodAttest28186\Exception;

use Exception;
use Throwable;

final class EmptyGivenNameException extends Exception
{
public function __construct($message = "", Throwable $previous = null)
{
parent::__construct($message, 0, $previous);
}
}
20 changes: 20 additions & 0 deletions src/Model/Child/ChildDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Tactics\FodAttest28186\Model\Child;

use Tactics\FodAttest28186\Exception\EmptyFamilyNameException;
use Tactics\FodAttest28186\Exception\EmptyGivenNameException;
use Tactics\FodAttest28186\Exception\InvalidTariffException;
use Tactics\FodAttest28186\ValueObject\Address;
use Tactics\FodAttest28186\ValueObject\DayOfBirth;

Expand Down Expand Up @@ -36,12 +39,29 @@ public function __construct(
$this->dayOfBirth = $dayOfBirth;
}

/**
* @throws EmptyGivenNameException
* @throws EmptyFamilyNameException
*/
public static function create(
string $familyName,
string $givenName,
Address $address,
DayOfBirth $dayOfBirth
): ChildDetails {

if (empty($givenName)) {
throw new EmptyGivenNameException(
'A child must have a given name'
);
}

if (empty($familyName)) {
throw new EmptyFamilyNameException(
'A child must have a family name'
);
}

return new self($familyName, $givenName, $address, $dayOfBirth);
}

Expand Down
19 changes: 19 additions & 0 deletions src/Model/Debtor/DebtorDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Tactics\FodAttest28186\Model\Debtor;

use Tactics\FodAttest28186\Exception\EmptyFamilyNameException;
use Tactics\FodAttest28186\Exception\EmptyGivenNameException;
use Tactics\FodAttest28186\ValueObject\Address;
use Tactics\FodAttest28186\ValueObject\DayOfBirth;

Expand Down Expand Up @@ -41,13 +43,30 @@ private function __construct(
$this->placeOfBirth = trim($placeOfBirth);
}

/**
* @throws EmptyGivenNameException
* @throws EmptyFamilyNameException
*/
public static function create(
string $familyName,
string $givenName,
Address $address,
DayOfBirth $dayOfBirth,
string $placeOfBirth
): DebtorDetails {

if (empty($givenName)) {
throw new EmptyGivenNameException(
'A debtor must have a given name'
);
}

if (empty($familyName)) {
throw new EmptyFamilyNameException(
'A debtor must have a family name'
);
}

return new self(
$familyName,
$givenName,
Expand Down

0 comments on commit f4ab9ef

Please sign in to comment.