Total Complexity | 5 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | class SymfonySchema implements SchemaInterface |
||
15 | { |
||
16 | const SCHEMA_URI = 'tag:symfony.com,2019:'; |
||
17 | const BUILDING_NAMESPACE = "\\Symfony\\Component"; |
||
18 | |||
19 | /** |
||
20 | * |
||
21 | * Specific Handler for Symfony custom tag : 'php/object' |
||
22 | * |
||
23 | * |
||
24 | * @throws \Exception if unserialize fails OR if its a NodeList (no support of multiple values for this tag) |
||
25 | */ |
||
26 | public final static function PHPobjectHandler(object $node): object |
||
27 | { |
||
28 | if ($node instanceof Scalar) { |
||
29 | $phpObject = unserialize($node->raw); |
||
30 | // NOTE : we assume this is only used for Object types (if a boolean false is serialized this will FAIL) |
||
31 | if (is_bool($phpObject)) { |
||
32 | throw new \Exception("value for tag 'php/object' could NOT be unserialized"); |
||
33 | } |
||
34 | return $phpObject; |
||
35 | } |
||
36 | throw new \Exception("tag 'php/object' value must NOT be a list"); |
||
37 | } |
||
38 | |||
39 | public function __call($name, $arguments) |
||
49 | } |
||
50 | } |
||
51 |