Completed
Push — master ( 229994...2c43c1 )
by Jack
01:58
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
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...
4
5
6
    public function run() {
7
		$json = $this->composerJsonObj->jsonData;
0 ignored issues
show
Bug introduced by
The property composerJsonObj does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
8
9
10
		if (property_exists($json, 'extra')) {
11
		
12
			GeneralMethods::outputToScreen("<li> already has composer.json </li>");
13
			
14
			return;
15
		}
16
17
		else {
18
			GeneralMethods::outputToScreen("<li> Adding 'extra' array to composer.json </li>");
19
			
20
			$json->extra  = (object)array('installer-name' => str_replace('silverstripe-', '', $this->composerJsonObj->moduleName)); 
21
		}
22
		
23
24
    }
25
}
26