Total Complexity | 39 |
Total Lines | 89 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
16 | class DelimiterAtom extends TextAtom |
||
17 | { |
||
18 | /** |
||
19 | * @param string $c |
||
20 | */ |
||
21 | public function __construct(string $c) |
||
22 | { |
||
23 | parent::__construct($c); |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @param string $c |
||
28 | * @return bool |
||
29 | */ |
||
30 | public static function isValidDelimiter(string $c): bool |
||
31 | { |
||
32 | if (\mb_strlen($c) > 1) { |
||
33 | return false; |
||
34 | } |
||
35 | |||
36 | switch ($c) { |
||
37 | // Basic Delimiters. |
||
38 | case '/': |
||
39 | case '.': |
||
40 | case '!': |
||
41 | case ',': |
||
42 | case ';': |
||
43 | case '?': |
||
44 | case ' ': |
||
45 | case '=': |
||
46 | case "'": |
||
47 | case '"': |
||
48 | case "\t": |
||
49 | case "\r": |
||
50 | case "\n": |
||
51 | // Extra Delimiters. |
||
52 | case '[': |
||
53 | case ']': |
||
54 | case '{': |
||
55 | case '}': |
||
56 | case '(': |
||
57 | case ')': |
||
58 | case '&': |
||
59 | case '|': |
||
60 | case "\\": |
||
61 | case '-': |
||
62 | case '_': |
||
63 | case '+': |
||
64 | case '*': |
||
65 | case ':': |
||
66 | return true; |
||
67 | } |
||
68 | |||
69 | return false; |
||
70 | } |
||
71 | |||
72 | /** {@inheritdoc} */ |
||
73 | public function isValidAtom(string $c): bool |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @param string $c |
||
80 | * @return bool |
||
81 | */ |
||
82 | private function isValidDelimiterAtom(string $c): bool |
||
83 | { |
||
84 | return self::isValidDelimiter($c); |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * @return string |
||
89 | */ |
||
90 | public function __toString(): string |
||
96 | } |
||
97 | |||
98 | /** {@inheritdoc} */ |
||
99 | public function equalsIdentifier(AtomInterface $other): bool |
||
105 | } |
||
106 | } |
||
107 |