Conditions | 2 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
33 | protected function generateLocalePath(): string |
||
34 | { |
||
35 | $pattern = '/(?<entity_name>^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)(?<postfix>State)$/'; |
||
36 | $matches = []; |
||
37 | |||
38 | // if the class name matches the state class rule then the $matches[1] is value will be the entity name |
||
39 | // else throw an exception |
||
40 | if (! preg_match($pattern, $this->reflection->getShortName(), $matches)) { |
||
41 | throw new Exception("The {$this->reflection->getShortName()} doesn't match the state class name rule."); |
||
42 | } |
||
43 | |||
44 | $entity_name = $this->makeSnakeCase($matches['entity_name']); |
||
45 | |||
46 | return "entities/{$entity_name}"; |
||
47 | } |
||
49 |