MemoryStorage   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 19
rs 10
c 0
b 0
f 0
ccs 7
cts 7
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A load() 0 7 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