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

CheckOrAddExtraArray::run()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 11
nc 3
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
    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