Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
49 | 33 | public function createAlias(string ...$patterns): string |
|
50 | { |
||
51 | 33 | if (\count($patterns)) { |
|
52 | 30 | $patterns = \array_map(function(string $pattern) { |
|
53 | 30 | return \preg_replace('/\W+/iu', '', \snake_case(\class_basename($pattern))); |
|
54 | 30 | }, $patterns); |
|
55 | |||
56 | 30 | $pattern = \implode('_', $patterns); |
|
57 | |||
58 | 30 | if (\trim($pattern)) { |
|
59 | 30 | return \sprintf('%s_%d', $pattern, ++static::$lastQueryId); |
|
60 | } |
||
61 | } |
||
62 | |||
63 | 3 | return 'q' . Str::random(7) . '_' . ++static::$lastQueryId; |
|
64 | } |
||
65 | |||
90 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: