| Conditions | 5 |
| Paths | 7 |
| Total Lines | 21 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 5 |
| Changes | 4 | ||
| Bugs | 3 | Features | 0 |
| 1 | <?php |
||
| 18 | 55 | public function getName() |
|
| 19 | { |
||
| 20 | 55 | if (!empty($this->config)) { |
|
| 21 | 46 | return $this->config->getName(); |
|
|
|
|||
| 22 | } |
||
| 23 | |||
| 24 | 37 | $className = get_called_class(); |
|
| 25 | |||
| 26 | 37 | if ($prevPos = strrpos($className, '\\')) { |
|
| 27 | 37 | $className = substr($className, $prevPos + 1); |
|
| 28 | 37 | } |
|
| 29 | |||
| 30 | 37 | if (substr($className, -5) == 'Field') { |
|
| 31 | 3 | $className = lcfirst(substr($className, 0, -5)); |
|
| 32 | 37 | } elseif (substr($className, -4) == 'Type') { |
|
| 33 | 34 | $className = substr($className, 0, -4); |
|
| 34 | 34 | } |
|
| 35 | |||
| 36 | |||
| 37 | 37 | return $className; |
|
| 38 | } |
||
| 39 | |||
| 41 |
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: