Passed
Pull Request — main (#1074)
by
unknown
03:19
created

TableOfContentsWrapper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 17
ccs 6
cts 12
cp 0.5
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getInnerToc() 0 15 3
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