| Total Complexity | 9 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | final class Argument |
||
| 12 | { |
||
| 13 | private $name; |
||
| 14 | private $type; |
||
| 15 | private $optional = false; |
||
| 16 | private $default; |
||
| 17 | |||
| 18 | 10 | public function __construct(Name $name, Type $type) |
|
| 19 | { |
||
| 20 | 10 | $this->name = $name; |
|
| 21 | 10 | $this->type = $type; |
|
| 22 | 10 | } |
|
| 23 | |||
| 24 | 9 | public function name(): Name |
|
| 25 | { |
||
| 26 | 9 | return $this->name; |
|
| 27 | } |
||
| 28 | |||
| 29 | 3 | public function makeOptional(): self |
|
| 30 | { |
||
| 31 | 3 | $self = clone $this; |
|
| 32 | 3 | $self->optional = true; |
|
| 33 | |||
| 34 | 3 | return $self; |
|
| 35 | } |
||
| 36 | |||
| 37 | 3 | public function defaultsTo(Name $name): self |
|
| 38 | { |
||
| 39 | 3 | $self = clone $this; |
|
| 40 | 3 | $self->default = $name; |
|
| 41 | |||
| 42 | 3 | return $self; |
|
| 43 | } |
||
| 44 | |||
| 45 | 10 | public function optional(): bool |
|
| 48 | } |
||
| 49 | |||
| 50 | 8 | public function hasDefault(): bool |
|
| 53 | } |
||
| 54 | |||
| 55 | 2 | public function default(): Name |
|
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @param mixed $value |
||
| 62 | * |
||
| 63 | * @throws InvalidArgument |
||
| 64 | */ |
||
| 65 | 6 | public function validate($value): void |
|
| 72 |