Completed
Push — master ( 965d61...bf91ef )
by Nicolaas
03:12
created

CheckOrAddExtraArray   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 23
rs 10
c 0
b 0
f 0
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
8
    public function run() {
9
        $json = $this->getJsonData();
10
11
        if (isset($json['extra'])) {
12
13
            GeneralMethods::outputToScreen("<li> already has composer.json[extra][installer-name] </li>");
14
15
            return;
16
        }
17
18
        else {
19
            GeneralMethods::outputToScreen("<li> Adding 'extra' array to composer.json </li>");
20
            if(! isset($json['extra'])) {
21
                $json['extra'] = [];
22
            }
23
            $json['extra']['installer-name'] = str_replace('silverstripe-', '', $this->composerJsonObj->moduleName));
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected ')'
Loading history...
24
        }
25
        $this->setJsonData($json);
26
    }
27
}
28