Passed
Pull Request — main (#123)
by Andrey
38:21 queued 23:20
created

Base   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A correct() 0 10 2
A doesntExists() 0 3 1
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\Facades\Helpers\Ables\Arrayable;
26
use Helldar\Support\Facades\Helpers\Filesystem\File;
27
28
abstract class Base implements Filesystem
29
{
30
    use Has;
31
    use Paths;
32
33
    protected function doesntExists(string $path): bool
34
    {
35
        return ! File::exists($path);
36
    }
37
38
    protected function correct(array $items): array
39
    {
40
        $callback = static function ($value) {
41
            return is_string($value) ? stripslashes($value) : $value;
42
        };
43
44
        return Arrayable::of($items)
45
            ->map($callback, true)
46
            ->renameKeys($callback)
47
            ->get();
48
    }
49
}
50