| Total Complexity | 6 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 92.86% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | trait HasNameTrait |
||
| 12 | { |
||
| 13 | |||
| 14 | protected $name = null; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @return string |
||
| 18 | */ |
||
| 19 | 15 | public function getName() |
|
| 20 | { |
||
| 21 | 15 | if ($this->name == null) { |
|
| 22 | 15 | $this->initName(); |
|
| 23 | } |
||
| 24 | |||
| 25 | 15 | return $this->name; |
|
| 26 | } |
||
| 27 | |||
| 28 | 15 | public function initName() |
|
| 29 | { |
||
| 30 | 15 | $this->name = $this->generateName(); |
|
| 31 | 15 | } |
|
| 32 | |||
| 33 | /** |
||
| 34 | * @return string |
||
| 35 | */ |
||
| 36 | 15 | public function generateName() |
|
| 37 | { |
||
| 38 | 15 | $name = $this->generateNameFromClass(); |
|
| 39 | 15 | $name = inflector()->unclassify($name); |
|
| 40 | |||
| 41 | 15 | return $name; |
|
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @return string |
||
| 46 | */ |
||
| 47 | 12 | protected function generateNameFromClass() |
|
| 52 | } |
||
| 53 | } |
||
| 54 | } |
||
| 55 |