CheckOrAddExtraArray   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 11
c 1
b 0
f 1
dl 0
loc 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 16 3
1
<?php
2
/**
3
 * sets the default installation folder
4
 */
5
class CheckOrAddExtraArray extends UpdateComposer
6
{
7
    public function run()
8
    {
9
        $json = $this->getJsonData();
10
11
        if (isset($json['extra'])) {
12
            GeneralMethods::output_to_screen("<li> already has composer.json[extra][installer-name] </li>");
13
14
            return;
15
        } else {
16
            GeneralMethods::output_to_screen("<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