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 |
||
21 | 4 | public function getInnerToc(): TableOfContents |
|
22 | { |
||
23 | 4 | $children = $this->children(); |
|
24 | 4 | if (! \is_array($children)) { |
|
|
|||
25 | /** @psalm-suppress NoValue */ |
||
26 | $children = \iterator_to_array($children); |
||
27 | } |
||
28 | |||
29 | 4 | if (\count($children) !== 2) { |
|
30 | throw new InvalidArgumentException( |
||
31 | 'TableOfContentsWrapper nodes should have 2 children, found ' . \count($children) |
||
32 | ); |
||
33 | } |
||
34 | |||
35 | 4 | $inner = $children[1]; |
|
36 | 4 | if (! $inner instanceof TableOfContents) { |
|
37 | throw new InvalidArgumentException( |
||
38 | 'TableOfContentsWrapper second node should be a TableOfContents, found ' . \get_class($inner) |
||
39 | ); |
||
40 | } |
||
41 | |||
42 | 4 | return $inner; |
|
43 | } |
||
45 |