Completed
Push — master ( 1385c4...94a8d3 )
by Nicolaas
01:48
created

CheckOrAddExtraArray   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 17 3
1
<?php
2
/**
3
 * sets the default installation folder
4
 */
5
class CheckOrAddExtraArray extends UpdateComposer
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
{
7
    public function run()
8
    {
9
        $json = $this->getJsonData();
10
11
        if (isset($json['extra'])) {
12
            GeneralMethods::outputToScreen("<li> already has composer.json[extra][installer-name] </li>");
13
14
            return;
15
        } else {
16
            GeneralMethods::outputToScreen("<li> Adding 'extra' array to composer.json </li>");
17
            if (! isset($json['extra'])) {
18
                $json['extra'] = [];
19
            }
20
            $json['extra']['installer-name'] = str_replace('silverstripe-', '', $this->composerJsonObj->moduleName);
21
        }
22
        $this->setJsonData($json);
23
    }
24
}
25