Conditions | 3 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3.072 |
Changes | 0 |
1 | <?php |
||
14 | 8 | public function serialize(Reference $reference) |
|
15 | { |
||
16 | 8 | $stack = []; |
|
17 | 8 | $schema = $stack[] = $reference->resolve(); |
|
18 | |||
19 | 8 | while ($schema instanceof Reference) { |
|
20 | 2 | $resolved = $schema->resolve(); |
|
21 | 2 | if (in_array($resolved, $stack)) { |
|
22 | 2 | throw ReferenceSerializationException::circular($schema->getRef()); |
|
23 | } |
||
24 | $schema = $resolved; |
||
25 | } |
||
26 | |||
27 | 6 | return $schema; |
|
28 | } |
||
29 | } |
||
30 |