| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | private function incrementReferenceName($referenceName) |
||
| 35 | { |
||
| 36 | if (0 === preg_match('#^(.*)(\d+)$#', $referenceName)) { |
||
| 37 | if (1 === preg_match('#^(\w+):(\w+)#', $referenceName)) { |
||
| 38 | return sprintf('%s-1', $referenceName); |
||
| 39 | } else { |
||
| 40 | return sprintf('%s:1', $referenceName); |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | return preg_replace_callback( |
||
| 45 | '#^(.*)(\d+)$#', |
||
| 46 | function ($matches) { return $matches[1].intval($matches[2]+1); }, |
||
| 47 | $referenceName |
||
| 48 | ); |
||
| 49 | } |
||
| 50 | } |
||
| 51 |
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: