Completed
Push — master ( 7d20ae...438ac0 )
by Michal
16:52 queued 13:26
created

Core::error()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
3
/**
4
 * Defines the core helper infrastructure of the library.
5
 */
6
7
namespace PhpMyAdmin\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 85
    public function error($error)
41
    {
42 85
        if ($this->strict) {
43 2
            throw $error;
44
        }
45 83
        $this->errors[] = $error;
46 83
    }
47
}
48