| Total Complexity | 5 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Coverage | 90.91% |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 9 | class Gender |
||
| 10 | { |
||
| 11 | public const GENDER_MALE = 'm'; |
||
| 12 | |||
| 13 | public const GENDER_FEMALE = 'f'; |
||
| 14 | |||
| 15 | private const ALLOWED_GENDERS = [ |
||
| 16 | self::GENDER_MALE, |
||
| 17 | self::GENDER_FEMALE, |
||
| 18 | ]; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $value; |
||
| 24 | |||
| 25 | 3 | public function __construct(string $value) |
|
| 26 | { |
||
| 27 | 3 | if (!\in_array($value, self::ALLOWED_GENDERS, true)) { |
|
| 28 | throw new InvalidGenderException(\sprintf('Gender %s is not allowed', $value)); |
||
| 29 | } |
||
| 30 | |||
| 31 | 3 | $this->value = $value; |
|
| 32 | 3 | } |
|
| 33 | |||
| 34 | 1 | public function __toString(): string |
|
| 35 | { |
||
| 36 | 1 | return $this->value; |
|
| 37 | } |
||
| 38 | |||
| 39 | 2 | public function getValue(): string |
|
| 42 | } |
||
| 43 | |||
| 44 | 1 | public function equals(self $referenceGender): bool |
|
| 49 |