Translatable   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTexts() 0 3 1
A addText() 0 7 2
A translate() 0 3 1
1
<?php
2
3
namespace EasyPanel\Concerns;
4
5
use EasyPanel\Support\Contract\LangManager;
6
7
trait Translatable
8
{
9
    protected $texts = [];
10
11
    public function addText($text, $key = null)
12
    {
13
        if (array_key_exists($key, $this->texts)){
14
            return;
15
        }
16
17
        $this->texts[$key ?? $text] = $text;
18
    }
19
20
    public function translate()
21
    {
22
        LangManager::updateAll($this->texts);
23
    }
24
25
    public function getTexts()
26
    {
27
        return $this->texts;
28
    }
29
}
30