Completed
Push — master ( d70775...825d10 )
by Kacper
02:48
created

Result::append()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * Highlighter
4
 *
5
 * Copyright (C) 2016, Some right reserved.
6
 *
7
 * @author Kacper "Kadet" Donat <[email protected]>
8
 *
9
 * Contact with author:
10
 * Xmpp: [email protected]
11
 * E-mail: [email protected]
12
 *
13
 * From Kadet with love.
14
 */
15
16
namespace Kadet\Highlighter\Parser;
17
18
19
use Kadet\Highlighter\Parser\Token\Token;
20
21
class Result extends \ArrayObject implements Tokens
22
{
23
    private $_source;
24
    private $_start;
25
26 13
    public function __construct($source, Token $start = null)
27
    {
28 13
        $this->_source = $source;
29 13
        $this->_start  = $start;
30
31 13
        parent::__construct($start !== null ? [ $start->id => $start ] : [], 0, \ArrayIterator::class);
32 13
    }
33
34 6
    public function getSource()
35
    {
36 6
        return $this->_source;
37
    }
38
39 4
    public function merge($tokens)
40
    {
41 4
        foreach ($tokens as $token) {
42 4
            $this->append($token);
43 4
        }
44 4
    }
45
46 1
    public function getTokens()
47
    {
48 1
        return $this->getArrayCopy();
49
    }
50
51 11
    public function getStart()
52
    {
53 11
        return $this->_start;
54
    }
55
}