| Total Complexity | 6 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 19 | final class Customer |
||
| 20 | { |
||
| 21 | /** @var string */ |
||
| 22 | private $lastName = ''; |
||
| 23 | |||
| 24 | /** @var string */ |
||
| 25 | private $firstName = ''; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * CustomerName constructor. |
||
| 29 | * @param string $firstName |
||
| 30 | * @param string $lastName |
||
| 31 | */ |
||
| 32 | public function __construct(string $firstName = '', string $lastName = '') |
||
| 33 | { |
||
| 34 | $firstName = trim($firstName); |
||
| 35 | $lastName = trim($lastName); |
||
| 36 | |||
| 37 | if ($this->validateAlpha($firstName)) { |
||
| 38 | $this->firstName = $firstName; |
||
| 39 | } |
||
| 40 | |||
| 41 | if ($this->validateAlpha($lastName)) { |
||
| 42 | $this->lastName = $lastName; |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Customer’s first name. |
||
| 48 | * @return string |
||
| 49 | */ |
||
| 50 | public function getFirstName(): string |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Customer’s last name |
||
| 57 | * @return string |
||
| 58 | */ |
||
| 59 | public function getLastName(): string |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Validate that a field contains only alphabetic characters |
||
| 66 | * @param string $value |
||
| 67 | * @return bool |
||
| 68 | */ |
||
| 69 | private function validateAlpha($value): bool |
||
| 72 | } |
||
| 73 | } |