Completed
Pull Request — master (#106)
by Michal
135:31 queued 70:13
created

Core::error()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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