PingJob::DNData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * Runs a capistrano job that will check the connection and that all folders with
5
 * permission are setup correctly
6
 */
7
class PingJob {
8
9
	/**
10
	 * @var array
11
	 */
12
	public $args;
13
14
	/**
15
	 * @global array $databaseConfig
16
	 */
17
	public function setUp() {
18
		global $databaseConfig;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
19
		DB::connect($databaseConfig);
20
		chdir(BASE_PATH);
21
	}
22
23
	/**
24
	 * @return DNData
25
	 */
26
	public function DNData() {
27
		return DNData::inst();
28
	}
29
30
	/**
31
	 * Do the actual job by calling the appropiate backend
32
	 */
33
	public function perform() {
34
		echo "[-] PingJob starting" . PHP_EOL;
35
		$log = new DeploynautLogFile($this->args['logfile']);
36
37
		$ping = DNPing::get()->byID($this->args['pingID']);
38
		$environment = $ping->Environment();
39
		$project = $environment->Project();
40
		$environment->Backend()->ping($environment, $log, $project);
41
	}
42
}
43