| Conditions | 6 |
| Paths | 5 |
| Total Lines | 22 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | public function __construct($value = null) |
||
| 13 | { |
||
| 14 | if (is_null($value) || $value == '') { |
||
| 15 | return; |
||
| 16 | } |
||
| 17 | |||
| 18 | if (is_array($value)) { |
||
| 19 | $object = (object)$value; |
||
| 20 | $this->importPropertiesFrom($object); |
||
| 21 | return; |
||
| 22 | } |
||
| 23 | |||
| 24 | if (is_string($value)) { |
||
| 25 | $object = json_decode($value); |
||
| 26 | if (!is_null($object)) { |
||
| 27 | $this->importPropertiesFrom($object); |
||
| 28 | return; |
||
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | throw new \InvalidArgumentException('Object can not be build from value ' . var_export($value, true)); |
||
| 33 | } |
||
| 34 | |||
| 61 |