Completed
Pull Request — master (#106)
by Michal
128:10 queued 63:32
created

Core   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 42
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A error() 0 7 2
1
<?php
2
3
/**
4
 * Defines the core helper infrastructure of the library.
5
 *
6
 * @package SqlParser
7
 */
8
namespace SqlParser;
9
10
class Core
11
{
12
13
    /**
14
     * Whether errors should throw exceptions or just be stored.
15
     *
16
     * @var bool
17
     *
18
     * @see static::$errors
19
     */
20
    public $strict = false;
21
22
    /**
23
     * List of errors that occurred during lexing.
24
     *
25
     * Usually, the lexing does not stop once an error occurred because that
26
     * error might be false positive or a partial result (even a bad one)
27
     * might be needed.
28
     *
29
     * @var Exception[]
30
     *
31
     * @see Core::error()
32
     */
33
    public $errors = array();
34
35
    /**
36
     * Creates a new error log.
37
     *
38
     * @param Exception $error The error exception.
39
     *
40
     * @throws Exception Throws the exception, if strict mode is enabled.
41
     *
42
     * @return void
43
     */
44
    public function error($error)
45
    {
46
        if ($this->strict) {
47
            throw $error;
48
        }
49
        $this->errors[] = $error;
50
    }
51
}
52