Test Setup Failed
Pull Request — latest (#3)
by Mark
31:31
created

Document   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 9
eloc 14
c 0
b 0
f 0
dl 0
loc 44
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setParent() 0 7 3
A setEndLine() 0 3 1
A getStartLine() 0 3 1
A __construct() 0 4 1
A setStartLine() 0 5 2
A getEndLine() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file was originally part of the league/commonmark package.
7
 *
8
 * (c) Colin O'Dell <[email protected]>
9
 *
10
 * Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
11
 *  - (c) John MacFarlane
12
 *
13
 * For the full copyright and license information, please view the LICENSE
14
 * file that was distributed with this source code.
15
 */
16
17
namespace UnicornFail\Emoji\Node;
18
19
class Document extends Node
20
{
21
    /** @var int|null */
22
    protected $startLine;
23
24
    /** @var int|null */
25
    protected $endLine;
26
27
    public function __construct()
28
    {
29
        parent::__construct();
30
        $this->setStartLine(1);
31
    }
32
33
    protected function setParent(?Node $node = null): void
34
    {
35
        if ($node && ! $node instanceof self) {
36
            throw new \InvalidArgumentException('Parent of block must also be block (cannot be inline)');
37
        }
38
39
        parent::setParent($node);
40
    }
41
42
    public function setStartLine(?int $startLine): void
43
    {
44
        $this->startLine = $startLine;
45
        if ($this->endLine === null) {
46
            $this->endLine = $startLine;
47
        }
48
    }
49
50
    public function getStartLine(): ?int
51
    {
52
        return $this->startLine;
53
    }
54
55
    public function setEndLine(?int $endLine): void
56
    {
57
        $this->endLine = $endLine;
58
    }
59
60
    public function getEndLine(): ?int
61
    {
62
        return $this->endLine;
63
    }
64
}
65