Completed
Push — master ( 32c328...253a84 )
by Valentin
15s queued 11s
created

JobInstance   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 11
c 1
b 0
f 0
dl 0
loc 56
ccs 14
cts 14
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setTaskInstances() 0 6 1
A __construct() 0 3 1
A getTaskInstances() 0 3 1
A removeTaskInstance() 0 4 1
A addTaskInstance() 0 4 1
1
<?php
2
3
4
namespace Pheanstalk\Structure;
5
6
use Doctrine\Common\Collections\ArrayCollection;
7
8
class JobInstance
9
{
10
    /** @var ArrayCollection[TaskInstance] */
0 ignored issues
show
Documentation Bug introduced by
The doc comment ArrayCollection[TaskInstance] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
11
    private $taskInstances;
12
13
    /**
14
     * JobInstance constructor.
15
     *
16
     * @param ArrayCollection[TaskInstance] $taskInstances
0 ignored issues
show
Documentation Bug introduced by
The doc comment ArrayCollection[TaskInstance] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
17
     */
18 8
    public function __construct(ArrayCollection $taskInstances)
19
    {
20 8
        $this->setTaskInstances($taskInstances);
21
    }
22
23
    /**
24
     * @return ArrayCollection
25
     */
26 2
    public function getTaskInstances(): ArrayCollection
27
    {
28 2
        return $this->taskInstances;
29
    }
30
31
    /**
32
     * @param ArrayCollection $taskInstances
33
     *
34
     * @return JobInstance
35
     */
36 8
    public function setTaskInstances(ArrayCollection $taskInstances): JobInstance
37
    {
38
        $this->taskInstances = $taskInstances->filter(function(TaskInstance $taskInstance) {
0 ignored issues
show
Unused Code introduced by
The parameter $taskInstance is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

38
        $this->taskInstances = $taskInstances->filter(function(/** @scrutinizer ignore-unused */ TaskInstance $taskInstance) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
39 8
            return true;
40 8
        });
41 8
        return $this;
42
    }
43
44
    /**
45
     * @param TaskInstance $taskInstance
46
     *
47
     * @return JobInstance
48
     */
49 1
    public function addTaskInstance(TaskInstance $taskInstance): JobInstance
50
    {
51 1
        $this->taskInstances[] = $taskInstance;
52 1
        return $this;
53
    }
54
55
    /**
56
     * @param TaskInstance $taskInstance
57
     *
58
     * @return JobInstance
59
     */
60 1
    public function removeTaskInstance(TaskInstance $taskInstance): JobInstance
61
    {
62 1
        $this->taskInstances->removeElement($taskInstance);
63 1
        return $this;
64
    }
65
}
66