AbstractParser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 42.86%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 25
ccs 3
cts 7
cp 0.4286
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A err() 0 6 1
1
<?php
2
/**
3
 * For licensing information, please see the LICENSE file accompanied with this file.
4
 *
5
 * @author Gerard van Helden <[email protected]>
6
 * @copyright 2012 Gerard van Helden <http://melp.nl>
7
 */
8
9
namespace Zicht\Tool\Script;
10
11
/**
12
 * Base class for parsing.
13
 */
14
abstract class AbstractParser implements ParserInterface
15
{
16
    /**
17
     * Constructs the parser with an optional parent parser
18
     *
19
     * @param ParserInterface $parent
20
     */
21 13
    public function __construct(ParserInterface $parent = null)
22
    {
23 13
        $this->parent = $parent;
0 ignored issues
show
Bug introduced by
The property parent does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
24 13
    }
25
26
    /**
27
     * Triggers a parse error
28
     *
29
     * @param TokenStream $stream
30
     * @return void
31
     */
32
    final public function err(TokenStream $stream)
33
    {
34
        throw new \UnexpectedValueException(
35
            "Unexpected input near {$stream->current()->value} at offset {$stream->key()}"
36
        );
37
    }
38
}