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

CheckOrAddExtraArray::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 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