Completed
Pull Request — master (#74)
by
unknown
06:53
created

DirectoriesHaveCorrectPermissions   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 61.53%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 58
ccs 8
cts 13
cp 0.6153
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A name() 0 4 1
A message() 0 6 1
A check() 0 10 1
1
<?php
2
3
namespace BeyondCode\SelfDiagnosis\Checks;
4
5
use Illuminate\Support\Collection;
6
use Illuminate\Filesystem\Filesystem;
7
8
class DirectoriesHaveCorrectPermissions implements Check
9
{
10
    /** @var Filesystem */
11
    private $filesystem;
12
13
    /** @var Collection */
14
    private $paths;
15
16
    /**
17
     * DirectoriesHaveCorrectPermissions constructor.
18
     * @param Filesystem $filesystem
19
     */
20 4
    public function __construct(Filesystem $filesystem)
21
    {
22 4
        $this->filesystem = $filesystem;
23 4
    }
24
25
    /**
26
     * The name of the check.
27
     *
28
     * @param array $config
29
     * @return string
30
     */
31
    public function name(array $config): string
32
    {
33
        return trans('self-diagnosis::checks.directories_have_correct_permissions.name');
34
    }
35
36
    /**
37
     * The error message to display in case the check does not pass.
38
     *
39
     * @param array $config
40
     * @return string
41
     */
42
    public function message(array $config): string
43
    {
44
        return trans('self-diagnosis::checks.directories_have_correct_permissions.message', [
45
            'directories' => $this->paths->implode(PHP_EOL),
46
        ]);
47
    }
48
49
    /**
50
     * Perform the actual verification of this check.
51
     *
52
     * @param array $config
53
     * @return bool
54
     */
55 4
    public function check(array $config): bool
56
    {
57 4
        $this->paths = Collection::make(array_get($config, 'directories', []));
0 ignored issues
show
Deprecated Code introduced by
The function array_get() has been deprecated with message: Arr::get() should be used directly instead. Will be removed in Laravel 5.9.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
58
59
        $this->paths = $this->paths->reject(function ($path) {
60 4
            return $this->filesystem->isWritable($path);
61 4
        });
62
63 4
        return $this->paths->isEmpty();
64
    }
65
}
66