Completed
Push — feature/ss4-upgrade ( f41a3f )
by
unknown
10:12
created

BuildAddonJob   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 23
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 7 2
A perform() 0 10 1
1
<?php
2
3
namespace SilverStripe\Addons\Jobs;
4
5
use SilverStripe\ORM\DB;
6
use SilverStripe\Addons\Model\Addon;
7
use SilverStripe\Core\Injector\Injector;
8
9
/**
10
 * A background job which builds a single add-on.
11
 */
12
class BuildAddonJob 
13
{
14
15
	public function setUp() {
16
		global $databaseConfig;
17
18
		if (!DB::isActive()) {
0 ignored issues
show
Bug introduced by
The method isActive() does not seem to exist on object<SilverStripe\ORM\DB>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
19
			DB::connect($databaseConfig);
20
		}
21
	}
22
23
	public function perform() 
24
	{
25
		$package = Addon::get()->byID($this->args['id']);
0 ignored issues
show
Bug introduced by
The property args 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...
26
		$builder = Injector::inst()->get('AddonBuilder');
27
28
		$builder->build($package);
29
30
		$package->BuildQueued = false;
31
		$package->write();
32
	}
33
34
}
35