MemoryStorage::load()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 3
nc 4
nop 2
crap 3
1
<?php
2
3
namespace UniMan\Core\Translator\Storage;
4
5
use UniMan\Core\Translator\Loader\LoaderInterface;
6
7
class MemoryStorage implements StorageInterface
8
{
9
    private $loader;
10
11
    private $translations = [];
12
13 48
    public function __construct(LoaderInterface $loader)
14
    {
15 48
        $this->loader = $loader;
16 48
    }
17
18 14
    public function load($language, $key)
19
    {
20 14
        if (!isset($this->translations[$language])) {
21 14
            $this->translations[$language] = $this->loader->load($language);
22
        }
23 14
        return isset($this->translations[$language][$key]) ? $this->translations[$language][$key] : null;
24
    }
25
}
26