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

Document::getEndLine()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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