Completed
Push — master ( 72206a...a05009 )
by Michael
11:12
created

PatchStatus   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 12 5
A addTask() 0 5 1
1
<?php
2
3
class PatchStatus
4
{
5
    /** @var string $patchClass class name of patch */
6
    public $patchClass;
7
8
    /** @var bool $applied true if this patch is applied, false if it is needed */
9
    public $applied = true;
10
11
    /** @var string[] $tasks tasks that need to be run */
12
    public $tasks = array();
13
14
    /** @var string[] $files files that need to be writable */
15
    public $files = array();
16
17
    /**
18
     * PatchStatus constructor.
19
     * @param XoopsUpgrade $patch
20
     */
21
    public function __construct(XoopsUpgrade $patch)
22
    {
23
        $this->patchClass = get_class($patch);
24
        foreach ($patch->tasks as $task) {
25
            if (!$patch->{"check_{$task}"}()) {
26
                $this->addTask($task);
27
            }
28
        }
29
        if (!empty($patch->usedFiles) && !$this->applied) {
30
            $this->files = $patch->usedFiles;
31
        }
32
    }
33
34
    /**
35
     * Add a task that needs to be run to the tasks property
36
     *
37
     * @param string $task task name
38
     */
39
    protected function addTask($task)
40
    {
41
        $this->tasks[] = $task;
42
        $this->applied = false;
43
    }
44
}
45