Passed
Push — main ( fac73b...8d20c8 )
by Andrey
27:54 queued 25:43
created

Translation::merge()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the "andrey-helldar/laravel-lang-publisher" project.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @author Andrey Helldar <[email protected]>
10
 *
11
 * @copyright 2021 Andrey Helldar
12
 *
13
 * @license MIT
14
 *
15
 * @see https://github.com/andrey-helldar/laravel-lang-publisher
16
 */
17
18
declare(strict_types=1);
19
20
namespace Helldar\LaravelLangPublisher\Resources;
21
22
use Helldar\Contracts\LangPublisher\Translation as Resource;
23
use Helldar\LaravelLangPublisher\Concerns\Arrayable;
24
use Helldar\Support\Concerns\Makeable;
25
26
class Translation implements Resource
27
{
28
    use Arrayable;
29
    use Makeable;
30
31
    protected $keys = [];
32
33
    protected $translations = [];
34
35 85
    public function getKeys(): array
36
    {
37 85
        return $this->keys;
38
    }
39
40 85
    public function keys(string $target, array $keys): Resource
41
    {
42 85
        $values = $this->keys[$target] ?? [];
43
44 85
        $this->keys[$target] = $this->combine($values, $keys);
45
46 85
        return $this;
47
    }
48
49 85
    public function translation(string $locale, string $target, array $translations): Resource
50
    {
51 85
        $values = $this->translations[$target][$locale] ?? [];
52
53 85
        $this->translations[$target][$locale] = $this->mergeArray($values, $translations);
54
55 85
        return $this;
56
    }
57
58 85
    public function getTranslations(): array
59
    {
60 85
        return $this->translations;
61
    }
62
}
63