Completed
Pull Request — master (#35)
by Michal
62:51
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
 * @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