| Total Complexity | 8 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 5 | trait HasTranslationTrait |
||
| 6 | { |
||
| 7 | |||
| 8 | protected $label = null; |
||
| 9 | |||
| 10 | protected $label_short = null; |
||
| 11 | |||
| 12 | |||
| 13 | /** |
||
| 14 | * Get Property label |
||
| 15 | * |
||
| 16 | * @param bool $short short flag |
||
| 17 | * |
||
| 18 | * @return null |
||
| 19 | */ |
||
| 20 | public function getLabel($short = false) |
||
| 21 | { |
||
| 22 | if (!$this->label) { |
||
| 23 | $this->label = $this->generateLabel(); |
||
| 24 | if ($this->hasShortLabel()) { |
||
|
|
|||
| 25 | $this->label_short = $this->generateLabelShort(); |
||
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | return $short ? $this->label_short : $this->label; |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param string $slug |
||
| 34 | * @return string |
||
| 35 | */ |
||
| 36 | public function translate($slug = '', $params = []) |
||
| 37 | { |
||
| 38 | $slug = empty($slug) ? $slug : '.' . $slug; |
||
| 39 | return $this->getManager()->translate($this->getLabelSlug() . '.' . $this->getName() . $slug, $params); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @return string |
||
| 44 | */ |
||
| 45 | protected function generateLabel() |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @return string |
||
| 52 | */ |
||
| 53 | protected function generateLabelShort() |
||
| 56 | } |
||
| 57 | } |