MakeBaseCommand   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 46
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A makeDirectory() 0 5 2
A findDefaultImplementation() 0 12 3
1
<?php
2
3
namespace OkayBueno\Repositories\Commands;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Filesystem\Filesystem;
7
8
/**
9
 * Class MakeBaseCommand
10
 * @package OkayBueno\Repositories\Commands
11
 */
12
class MakeBaseCommand extends Command
13
{
14
    protected $filesystem;
15
    protected $composer;
16
17
18
    /**
19
     * @param Filesystem $filesystem
20
     */
21
    public function __construct(
22
        Filesystem $filesystem
23
    )
24
    {
25
        parent::__construct();
26
        $this->filesystem = $filesystem;
27
        $this->composer = app()['composer'];
0 ignored issues
show
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

27
        $this->composer = /** @scrutinizer ignore-call */ app()['composer'];
Loading history...
28
    }
29
30
31
    /**
32
     * @param $path
33
     */
34
    protected function makeDirectory( $path )
35
    {
36
        if ( !$this->filesystem->isDirectory( $path ) )
37
        {
38
            $this->filesystem->makeDirectory( $path, 0775, true, true);
39
        }
40
    }
41
42
43
    /**
44
     * @return array|mixed|string
45
     */
46
    protected function findDefaultImplementation()
47
    {
48
        $implementationBindings = config( 'repositories.bindings' );
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

48
        $implementationBindings = /** @scrutinizer ignore-call */ config( 'repositories.bindings' );
Loading history...
49
50
        $filtered = array_filter( $implementationBindings, function( $k ) {
51
            return $k === 'default';
52
        });
53
54
        $default = array_keys($filtered);
55
        $default = is_array( $default ) ? $default[0] : $default;
0 ignored issues
show
introduced by
The condition is_array($default) is always true.
Loading history...
56
57
        return $default ? $default : 'eloquent';
58
    }
59
60
}