| 1 | <?php |
||
| 11 | final class Pair implements \JsonSerializable |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @param mixed $key The pair's key |
||
| 15 | */ |
||
| 16 | public $key; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @param mixed $value The pair's value |
||
| 20 | */ |
||
| 21 | public $value; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Creates a new instance. |
||
| 25 | * |
||
| 26 | * @param mixed $key |
||
| 27 | * @param mixed $value |
||
| 28 | */ |
||
| 29 | public function __construct($key = null, $value = null) |
||
| 34 | |||
| 35 | /** |
||
| 36 | * This allows unset($pair->key) to not completely remove the property, |
||
| 37 | * but be set to null instead. |
||
| 38 | * |
||
| 39 | * @param mixed $name |
||
| 40 | * |
||
| 41 | * @return mixed|null |
||
| 42 | */ |
||
| 43 | public function __unset($name) |
||
| 44 | { |
||
| 45 | if ($name === 'key' || $name === 'value') { |
||
| 46 | $this->$name = null; |
||
| 47 | return; |
||
| 48 | } |
||
| 49 | |||
| 50 | throw new OutOfBoundsException(); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Returns a copy of the Pair |
||
| 55 | * |
||
| 56 | * @return Pair |
||
| 57 | */ |
||
| 58 | public function copy(): Pair |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Returns a representation to be used for var_dump and print_r. |
||
| 65 | * |
||
| 66 | * @return array |
||
| 67 | */ |
||
| 68 | public function __debugInfo() |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @inheritDoc |
||
| 75 | */ |
||
| 76 | public function toArray(): array |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @inheritDoc |
||
| 83 | */ |
||
| 84 | public function jsonSerialize() |
||
| 88 | |||
| 89 | /** |
||
| 90 | * Returns a string representation of the pair. |
||
| 91 | */ |
||
| 92 | public function __toString() |
||
| 96 | } |
||
| 97 |