| Total Complexity | 9 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | class ObjectKeyValue implements KeyValueInterface |
||
| 14 | { |
||
| 15 | use KeyValueTrait; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var object |
||
| 19 | */ |
||
| 20 | protected $content; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * ObjectKeyValue constructor. |
||
| 24 | * @param object $content |
||
| 25 | */ |
||
| 26 | protected function __construct($content) |
||
| 27 | { |
||
| 28 | $this->content = $content; |
||
| 29 | } |
||
| 30 | |||
| 31 | |||
| 32 | /** |
||
| 33 | * @param object $content The content to be wrapped. |
||
| 34 | * @return static |
||
| 35 | */ |
||
| 36 | public static function wrap($content) |
||
| 37 | { |
||
| 38 | if ($content instanceof static) { |
||
| 39 | return $content; |
||
| 40 | } |
||
| 41 | |||
| 42 | if (is_object($content)) { |
||
| 43 | return new static($content); |
||
| 44 | } |
||
| 45 | |||
| 46 | throw new \InvalidArgumentException(); |
||
| 47 | } |
||
| 48 | |||
| 49 | public function set(string $key, $value) |
||
| 50 | { |
||
| 51 | $this->content->{$key} = $value; |
||
| 52 | } |
||
| 53 | |||
| 54 | public function delete(string $key) |
||
| 55 | { |
||
| 56 | unset($this->content->{$key}); |
||
| 57 | } |
||
| 58 | |||
| 59 | public function get(string $key) |
||
| 60 | { |
||
| 61 | return $this->content->{$key}; |
||
| 62 | } |
||
| 63 | |||
| 64 | public function exists(string $key) |
||
| 65 | { |
||
| 66 | return isset($this->content->{$key}); |
||
| 67 | } |
||
| 68 | |||
| 69 | public function getContent() |
||
| 72 | } |
||
| 73 | } |
||
| 74 |