Completed
Push — master ( 83739a...a13ee4 )
by Colin
14s queued 11s
created

Table   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 43
ccs 16
cts 18
cp 0.8889
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A canContain() 0 4 1
A isCode() 0 4 1
A getHead() 0 4 1
A getBody() 0 4 1
A matchesNextLine() 0 4 1
A handleRemainingContents() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This is part of the league/commonmark package.
7
 *
8
 * (c) Martin Hasoň <[email protected]>
9
 * (c) Webuni s.r.o. <[email protected]>
10
 * (c) Colin O'Dell <[email protected]>
11
 *
12
 * For the full copyright and license information, please view the LICENSE
13
 * file that was distributed with this source code.
14
 */
15
16
namespace League\CommonMark\Extension\Table;
17
18
use League\CommonMark\Block\Element\AbstractBlock;
19
use League\CommonMark\Block\Element\AbstractStringContainerBlock;
20
use League\CommonMark\Block\Element\InlineContainerInterface;
21
use League\CommonMark\ContextInterface;
22
use League\CommonMark\Cursor;
23
24
class Table extends AbstractStringContainerBlock implements InlineContainerInterface
25
{
26
    private $head;
27
    private $body;
28
    private $parser;
29
30 69
    public function __construct(\Closure $parser)
31
    {
32 69
        parent::__construct();
33 69
        $this->appendChild($this->head = new TableSection(TableSection::TYPE_HEAD));
34 69
        $this->appendChild($this->body = new TableSection(TableSection::TYPE_BODY));
35 69
        $this->parser = $parser;
36 69
    }
37
38
    public function canContain(AbstractBlock $block): bool
39
    {
40
        return $block instanceof TableSection;
41
    }
42
43 66
    public function isCode(): bool
44
    {
45 66
        return false;
46
    }
47
48 69
    public function getHead(): TableSection
49
    {
50 69
        return $this->head;
51
    }
52
53 66
    public function getBody(): TableSection
54
    {
55 66
        return $this->body;
56
    }
57
58 66
    public function matchesNextLine(Cursor $cursor): bool
59
    {
60 66
        return call_user_func($this->parser, $cursor, $this);
61
    }
62
63 69
    public function handleRemainingContents(ContextInterface $context, Cursor $cursor): void
64
    {
65 69
    }
66
}
67