Passed
Push — master ( 8d0399...707b07 )
by Reza
13:00
created

Translatable   A

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
4
namespace EasyPanel\Concerns;
5
6
7
use EasyPanel\Services\LangManager;
8
9
trait Translatable
10
{
11
    protected $texts = [];
12
13
    public function addText($text, $key = null)
14
    {
15
        if (array_key_exists($key, $this->texts)){
16
            return;
17
        }
18
19
        $this->texts[$key ?? $text] = $text;
20
    }
21
22
    public function translate()
23
    {
24
        LangManager::update($this->texts);
25
    }
26
27
    public function getTexts()
28
    {
29
        return $this->texts;
30
    }
31
}
32