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

Result   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 7
c 5
b 0
f 0
lcom 0
cbo 1
dl 0
loc 35
ccs 16
cts 16
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A getSource() 0 4 1
A merge() 0 6 2
A getTokens() 0 4 1
A getStart() 0 4 1
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
}