| Total Complexity | 6 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 9 | class Entry |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var Type |
||
| 13 | */ |
||
| 14 | protected $type; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var Gender |
||
| 18 | */ |
||
| 19 | protected $gender; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var string |
||
| 23 | */ |
||
| 24 | protected $value; |
||
| 25 | |||
| 26 | 3 | protected function __construct(Type $type, Gender $gender, string $value) |
|
| 27 | { |
||
| 28 | 3 | $this->type = $type; |
|
| 29 | 3 | $this->gender = $gender; |
|
| 30 | 3 | $this->value = $value; |
|
| 31 | 3 | } |
|
| 32 | |||
| 33 | 4 | public static function fromArray(array $data): self |
|
| 34 | { |
||
| 35 | 4 | if ($diff = \array_diff(['type', 'gender', 'value'], \array_keys($data))) { |
|
| 36 | 1 | throw new InvalidEntryInputDataException('Input entry keys missing', $diff); |
|
| 37 | } |
||
| 38 | |||
| 39 | 3 | return new static(new Type($data['type']), new Gender($data['gender']), $data['value']); |
|
| 40 | } |
||
| 41 | |||
| 42 | 1 | public function getType(): Type |
|
| 43 | { |
||
| 44 | 1 | return $this->type; |
|
| 45 | } |
||
| 46 | |||
| 47 | 1 | public function getGender(): Gender |
|
| 48 | { |
||
| 49 | 1 | return $this->gender; |
|
| 50 | } |
||
| 51 | |||
| 52 | 1 | public function getValue(): string |
|
| 55 | } |
||
| 56 | } |
||
| 57 |