PointcutLexer::__construct()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 56

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 33
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 56
ccs 33
cts 33
cp 1
rs 8.9599
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
declare(strict_types=1);
4
/*
5
 * Go! AOP framework
6
 *
7
 * @copyright Copyright 2013, Lisachenko Alexander <[email protected]>
8
 *
9
 * This source file is subject to the license that is bundled
10
 * with this source code in the file LICENSE.
11
 */
12
13
namespace Go\Aop\Pointcut;
14
15
use Dissect\Lexer\SimpleLexer;
16
17
/**
18
 * This class defines a lexer for pointcut expression
19
 */
20
class PointcutLexer extends SimpleLexer
21
{
22
    /**
23
     * Lexer token definitions
24
     */
25 31
    public function __construct()
26
    {
27
        // General tokens
28 31
        $this->token('execution');
29 31
        $this->token('dynamic');
30 31
        $this->token('within');
31 31
        $this->token('access');
32 31
        $this->token('cflowbelow');
33 31
        $this->token('initialization');
34 31
        $this->token('staticinitialization');
35 31
        $this->token('matchInherited');
36
37
        // Parenthesis
38 31
        $this->token('(');
39 31
        $this->token(')');
40
41
        // Member modifiers
42 31
        $this->token('public');
43 31
        $this->token('protected');
44 31
        $this->token('private');
45 31
        $this->token('final');
46
47
        // Access type (dynamic or static)
48 31
        $this->token('->');
49 31
        $this->token('::');
50
51
        // Logic tokens
52 31
        $this->token('!');
53 31
        $this->token('&');
54 31
        $this->token('&&');
55 31
        $this->token('|');
56 31
        $this->token('||');
57
58 31
        $this->token('annotation', '@');
59
60
        // Regex for class name
61 31
        $this->regex('namePart', '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/');
62
63
        // NS separator
64 31
        $this->token('nsSeparator', '\\');
65
66
        // Return-type specifier
67 31
        $this->token(':');
68
69
        // Special wildcard tokens
70 31
        $this->token('+');
71 31
        $this->token('*');
72 31
        $this->token('**');
73
74
        // White spaces
75 31
        $this->regex('WSP', "/^[ \r\n\t]+/");
76
77
        // Comments
78 31
        $this->regex('CMT', '|^//.*|');
79 31
        $this->skip('CMT', 'WSP');
80 31
    }
81
}
82