Pipeline   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 51
ccs 8
cts 10
cp 0.8
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A failed() 0 6 1
A succeeded() 0 4 1
A getResults() 0 4 1
A setResults() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of Rocketeer
5
 *
6
 * (c) Maxime Fabre <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 */
12
13
namespace Rocketeer\Services\Tasks;
14
15
use Illuminate\Support\Collection;
16
17
/**
18
 * A class representing a pipeline of jobs
19
 * to be executed.
20
 */
21
class Pipeline extends Collection
22
{
23
    /**
24
     * The stored results of each task.
25
     *
26
     * @var array
27
     */
28
    protected $results = [];
29
30
    //////////////////////////////////////////////////////////////////////
31
    ////////////////////////////// RESULTS ///////////////////////////////
32
    //////////////////////////////////////////////////////////////////////
33
34
    /**
35
     * Check if the pipeline failed.
36
     *
37
     * @return bool
38
     */
39 6
    public function failed()
40
    {
41 6
        $succeeded = count(array_filter($this->results));
42
43 6
        return $succeeded !== $this->count();
44
    }
45
46
    /**
47
     * Check if the pipeline ran its course.
48
     *
49
     * @return bool
50
     */
51 5
    public function succeeded()
52
    {
53 5
        return !$this->failed();
54
    }
55
56
    /**
57
     * @return array
58
     */
59
    public function getResults()
60
    {
61
        return $this->results;
62
    }
63
64
    /**
65
     * @param array $results
66
     */
67 20
    public function setResults($results)
68
    {
69 20
        $this->results = $results;
70 20
    }
71
}
72