| Total Complexity | 9 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | abstract class AbstractObject implements ObjectInterface |
||
| 8 | { |
||
| 9 | abstract protected function acceptsObject(): string; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Prevent from overriding constructor. |
||
| 13 | */ |
||
| 14 | final public function __construct() |
||
| 15 | { |
||
| 16 | } |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @return ObjectInterface|static |
||
| 20 | * |
||
| 21 | * @throws InvalidArgumentException |
||
| 22 | */ |
||
| 23 | public static function fromJsonString(string $json): ObjectInterface |
||
| 24 | { |
||
| 25 | $instance = new static(); |
||
| 26 | |||
| 27 | return static::fromArray($instance->validateInput($json)); |
||
| 28 | } |
||
| 29 | |||
| 30 | public static function fromArray(array $data): ObjectInterface |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @return array JSON decoded into array |
||
| 47 | */ |
||
| 48 | public function validateInput(string $json): array |
||
| 59 |