Passed
Pull Request — main (#1074)
by
unknown
04:44 queued 02:25
created

TableOfContentsWrapper::getInnerToc()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4.125

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 9
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 15
ccs 6
cts 12
cp 0.5
crap 4.125
rs 9.9666
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the league/commonmark package.
7
 *
8
 * (c) Colin O'Dell <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace League\CommonMark\Extension\TableOfContents\Node;
15
16
use League\CommonMark\Node\Block\AbstractBlock;
17
18
final class TableOfContentsWrapper extends AbstractBlock
19
{
20 4
    public function getInnerToc(): TableOfContents
21
    {
22 4
        $children = $this->children();
23 4
        if (count($children) != 2) {
24
            throw new InvalidArgumentException(
0 ignored issues
show
Bug introduced by
The type League\CommonMark\Extens...nvalidArgumentException was not found. Did you mean InvalidArgumentException? If so, make sure to prefix the type with \.
Loading history...
25
                'TableOfContentsWrapper nodes should have 2 children, found ' . count($children)
26
            );
27
        }
28 4
        $inner = $children[1];
29 4
        if (! $inner instanceof TableOfContents) {
30
            throw new InvalidArgumentException(
31
                'TableOfContentsWrapper second node should be a TableOfContents, found ' . get_class($inner)
32
            );
33
        }
34 4
        return $inner;
35
    }
36
}
37