| Conditions | 4 |
| Paths | 6 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 39 | 6 | public function apply(AbstractNode $node) |
|
| 40 | { |
||
| 41 | 6 | $allowUnderscore = $this->getBooleanProperty('allow-underscore'); |
|
| 42 | |||
| 43 | 6 | $pattern = '/^\$[a-zA-Z][a-zA-Z0-9]*$/'; |
|
| 44 | 6 | if ($allowUnderscore == true) { |
|
|
|
|||
| 45 | 2 | $pattern = '/^\$[_]?[a-zA-Z][a-zA-Z0-9]*$/'; |
|
| 46 | } |
||
| 47 | |||
| 48 | 6 | foreach ($node->getProperties() as $property) { |
|
| 49 | 6 | $propertyName = $property->getName(); |
|
| 50 | |||
| 51 | 6 | if (!preg_match($pattern, $propertyName)) { |
|
| 52 | 2 | $this->addViolation( |
|
| 53 | 2 | $node, |
|
| 54 | array( |
||
| 55 | 6 | $propertyName, |
|
| 56 | ) |
||
| 57 | ); |
||
| 58 | } |
||
| 59 | } |
||
| 60 | 6 | } |
|
| 61 | } |
||
| 62 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.