Passed
Push — main ( 55f929...127e84 )
by Andrey
161:41 queued 158:10
created

Manager::filesystem()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Services\Filesystem;
4
5
use Helldar\LaravelLangPublisher\Concerns\Containable;
6
use Helldar\LaravelLangPublisher\Concerns\Contains;
7
use Helldar\LaravelLangPublisher\Concerns\Logger;
8
use Helldar\LaravelLangPublisher\Contracts\Filesystem as Contract;
9
10
final class Manager implements Contract
11
{
12
    use Containable;
13
    use Contains;
14
    use Logger;
0 ignored issues
show
Bug introduced by
The trait Helldar\LaravelLangPublisher\Concerns\Logger requires the property $output which is not provided by Helldar\LaravelLangPubli...ices\Filesystem\Manager.
Loading history...
15
16 11
    public function load(string $path): array
17
    {
18 11
        $this->log('Loading data from an array: ' . $path);
19
20 11
        return $this->filesystem($path)->load($path);
21
    }
22
23 11
    public function store(string $path, array $content)
24
    {
25 11
        $this->log('Saving an array to a file: ' . $path);
26
27 11
        return $this->filesystem($path)->store($path, $content);
28
    }
29
30 11
    protected function filesystem(string $path): Contract
31
    {
32 11
        $this->log('Getting an object for working with files by the path: ' . $path);
33
34 11
        return $this->isJson($path)
35 11
            ? $this->container(Json::class)
36 11
            : $this->container(Php::class);
37
    }
38
}
39