Passed
Push — master ( bcac8b...ca1b68 )
by Reza
03:47
created

Translatable::translate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
4
namespace EasyPanel\Parsers;
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