Passed
Pull Request — main (#22)
by Andrey
11:55
created

Filesystem::put()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 2
rs 10
1
<?php
2
3
namespace Helldar\Support\Helpers;
4
5
class Filesystem
6
{
7
    public function store(array $array, string $path, bool $is_json = false, bool $sort_keys = false): void
8
    {
9
        $is_json
10
            ? $this->storeArrayAsJson($array, $path, $sort_keys)
11
            : $this->storeArrayAsArray($array, $path, $sort_keys);
12
    }
13
14
    public function storeArrayAsJson(array $array, string $path, bool $sort_keys = false): void
15
    {
16
        if ($sort_keys) {
17
            ksort($array);
18
        }
19
20
        $replace = ['{{slot}}' => json_encode($array)];
21
22
        $content = Stub::replace(Stub::LANG_JSON, $replace);
0 ignored issues
show
Bug introduced by
The type Helldar\Support\Helpers\Stub was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
24
        $this->put($path, $content);
25
    }
26
27
    public function storeArrayAsArray(array $array, string $path, bool $sort_keys = false): void
28
    {
29
        if ($sort_keys) {
30
            ksort($array);
31
        }
32
33
        $replace = ['{{slot}}' => var_export($array, true)];
34
35
        $content = Stub::replace(Stub::CONFIG_FILE, $replace);
36
37
        $this->put($path, $content);
38
    }
39
40
    public function put(string $path, string $content): void
0 ignored issues
show
Unused Code introduced by
The parameter $content is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

40
    public function put(string $path, /** @scrutinizer ignore-unused */ string $content): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $path is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

40
    public function put(/** @scrutinizer ignore-unused */ string $path, string $content): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
41
    {
42
43
    }
44
}
45