Conditions | 4 |
Paths | 6 |
Total Lines | 22 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | 4 | public function getInnerToc(): TableOfContents |
|
25 | { |
||
26 | 4 | $children = $this->children(); |
|
27 | 4 | if (! \is_array($children)) { |
|
|
|||
28 | /** @psalm-suppress NoValue */ |
||
29 | $children = \iterator_to_array($children); |
||
30 | } |
||
31 | |||
32 | 4 | if (\count($children) !== 2) { |
|
33 | throw new InvalidArgumentException( |
||
34 | 'TableOfContentsWrapper nodes should have 2 children, found ' . \count($children) |
||
35 | ); |
||
36 | } |
||
37 | |||
38 | 4 | $inner = $children[1]; |
|
39 | 4 | if (! $inner instanceof TableOfContents) { |
|
40 | throw new InvalidArgumentException( |
||
41 | 'TableOfContentsWrapper second node should be a TableOfContents, found ' . \get_class($inner) |
||
42 | ); |
||
43 | } |
||
44 | |||
45 | 4 | return $inner; |
|
46 | } |
||
48 |