Completed
Push — master ( 65f66e...428edc )
by Michal
04:14
created

Component   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 56
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 9 1
A build() 0 6 1
A __toString() 0 4 1
1
<?php
2
3
/**
4
 * Defines a component that is later extended to parse specialized components or
5
 * keywords.
6
 *
7
 * There is a small difference between *Component and *Keyword classes: usually,
8
 * *Component parsers can be reused in multiple  situations and *Keyword parsers
9
 * count on the *Component classes to do their job.
10
 */
11
12
namespace PhpMyAdmin\SqlParser;
13
14 2
require_once 'common.php';
15
16
/**
17
 * A component (of a statement) is a part of a statement that is common to
18
 * multiple query types.
19
 *
20
 * @category Components
21
 *
22
 * @license  https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
23
 */
24
abstract class Component
25
{
26
    /**
27
     * Parses the tokens contained in the given list in the context of the given
28
     * parser.
29
     *
30
     * @param Parser     $parser  the parser that serves as context
31
     * @param TokensList $list    the list of tokens that are being parsed
32
     * @param array      $options parameters for parsing
33
     *
34
     * @throws \Exception not implemented yet
35
     *
36
     * @return mixed
37
     */
38 1
    public static function parse(
39
        Parser $parser,
40
        TokensList $list,
41
        array $options = array()
42
    ) {
43
        // This method should be abstract, but it can't be both static and
44
        // abstract.
45 1
        throw new \Exception(\__('Not implemented yet.'));
46
    }
47
48
    /**
49
     * Builds the string representation of a component of this type.
50
     *
51
     * In other words, this function represents the inverse function of
52
     * `static::parse`.
53
     *
54
     * @param mixed $component the component to be built
55
     * @param array $options   parameters for building
56
     *
57
     * @throws \Exception not implemented yet
58
     *
59
     * @return string
60
     */
61 1
    public static function build($component, array $options = array())
62
    {
63
        // This method should be abstract, but it can't be both static and
64
        // abstract.
65 1
        throw new \Exception(\__('Not implemented yet.'));
66
    }
67
68
    /**
69
     * Builds the string representation of a component of this type.
70
     *
71
     * @see static::build
72
     *
73
     * @return string
74
     */
75 36
    public function __toString()
76
    {
77 36
        return static::build($this);
78
    }
79
}
80