BackpackBaseConfigService::old()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Zoutapps\Laravel\Backpack\Branding\Services;
4
5
use Zoutapps\Laravel\Backpack\Branding\Commands\BrandingCommand;
6
use Zoutapps\Laravel\Backpack\Branding\Traits\ValueReplacerTrait;
7
8
class BackpackBaseConfigService
9
{
10
    use ValueReplacerTrait;
11
12
    private $command;
13
14
    private $keys = [
0 ignored issues
show
Unused Code introduced by
The property $keys is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
15
        "project_name",
16
        "logo_lg",
17
        "logo_mini",
18
        "developer_name",
19
        "developer_link",
20
        "show_powered_by",
21
        "skin",
22
        "default_date_format",
23
        "default_datetime_format",
24
        "route_prefix",
25
    ];
26
27
    public function __construct(BrandingCommand $command, $file)
28
    {
29
        $this->command = $command;
30
        $this->file = $file;
31
        $this->appends = false;
32
        $this->defaults= collect(collect($this->command->getDefaults('config'))->get('backpack_base'));
33
    }
34
35 View Code Duplication
    public function perform()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    {
37
        if (file_exists($this->file) === false) {
38
            $this->command->error('You don\'t have a the backpack base config file.');
39
            return false;
40
        }
41
42
        $this->command->info('Please provide your base config values:');
43
44
        $this->applyValues();
45
46
        //$user_model_fqn
47
        return true;
48
    }
49
50
    protected function escape($value)
51
    {
52
        return "'".$value."'";
53
    }
54
55
    protected function old($key)
56
    {
57
        return $this->escape(config('backpack.base:'.$key));
58
    }
59
60
    protected function search($key, $old)
0 ignored issues
show
Unused Code introduced by
The parameter $old is not used and could be removed.

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

Loading history...
61
    {
62
        return '/^[ ]*'.preg_quote("'{$key}'").'[ ]*'.preg_quote("=>").'.*$/m';
63
    }
64
65
    protected function replace($key, $value) {
66
        return "    '".$key."' => ". $value . ",";
67
    }
68
}