Passed
Push — master ( 51edae...d29a9b )
by Curtis
11:52 queued 05:54
created

Reader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 3 1
A filename() 0 5 1
1
<?php
2
3
namespace App\Service\enso\Localisation\Json;
4
5
use LaravelEnso\Helpers\Services\JsonReader;
6
use App\Models\enso\Localisation\Language;
7
use LaravelEnso\Localisation\Services\Traits\JsonFilePathResolver;
8
9
class Reader
10
{
11
    use JsonFilePathResolver;
12
13
    private Language $language;
14
    private string $subDirectory;
15
16
    public function __construct(Language $language, ?string $subDirectory = null)
17
    {
18
        $this->language = $language;
19
        $this->subDirectory = $subDirectory;
20
    }
21
22
    public function get(): string
23
    {
24
        return (new JsonReader($this->filename()))->json();
25
    }
26
27
    private function filename(): string
28
    {
29
        return $this->jsonFileName(
30
            $this->language->name,
31
            $this->subDirectory
32
        );
33
    }
34
}
35