Passed
Pull Request — main (#123)
by Andrey
27:30 queued 12:28
created

Manager   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
dl 0
loc 21
rs 10
c 2
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 3 1
A store() 0 3 1
A filesystem() 0 5 2
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\Support\Filesystem;
21
22
use Helldar\Contracts\Support\Filesystem;
23
use Helldar\LaravelLangPublisher\Concerns\Has;
24
use Helldar\LaravelLangPublisher\Concerns\Paths;
25
use Helldar\Support\Concerns\Resolvable;
26
27
class Manager
28
{
29
    use Has;
30
    use Paths;
31
    use Resolvable;
32
33
    public function load(string $path): array
34
    {
35
        return $this->filesystem($path)->load($path);
36
    }
37
38
    public function store(string $path, array $content): void
39
    {
40
        $this->filesystem($path)->store($path, $content);
41
    }
42
43
    protected function filesystem(string $path): Filesystem
44
    {
45
        return $this->hasJson($path)
46
            ? static::resolveInstance(Json::class)
47
            : static::resolveInstance(Php::class);
48
    }
49
}
50