| Total Complexity | 7 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | final class Pair |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var bool|float|int|string |
||
| 11 | */ |
||
| 12 | private $key; |
||
|
|
|||
| 13 | |||
| 14 | /** |
||
| 15 | * @var mixed |
||
| 16 | */ |
||
| 17 | private $value; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param scalar $key |
||
| 21 | * @param mixed $value |
||
| 22 | */ |
||
| 23 | 50 | public static function factory($key, $value): Pair |
|
| 24 | { |
||
| 25 | 50 | assertScalar($key, "Key must be a scalar."); |
|
| 26 | 49 | return new self($key, $value); |
|
| 27 | 49 | } |
|
| 28 | 49 | ||
| 29 | /** |
||
| 30 | * @param scalar $key |
||
| 31 | * @param mixed $value |
||
| 32 | */ |
||
| 33 | 49 | private function __construct($key, $value) |
|
| 34 | { |
||
| 35 | 49 | $this->key = $key; |
|
| 36 | $this->value = $value; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @return scalar |
||
| 41 | 49 | */ |
|
| 42 | public function getKey() |
||
| 43 | 49 | { |
|
| 44 | return $this->key; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @return mixed |
||
| 49 | */ |
||
| 50 | public function getValue() |
||
| 51 | { |
||
| 52 | return $this->value; |
||
| 53 | } |
||
| 54 | |||
| 55 | public function copy($key = null, $value = null): Pair |
||
| 60 | ); |
||
| 61 | } |
||
| 62 | } |
||
| 63 | |||
| 64 |