Completed
Push — master ( 84b8e9...9ac9a8 )
by Valentin
03:43
created

JobInstance::getTaskInstances()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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 7
    public function __construct(ArrayCollection $taskInstances)
19
    {
20 7
        $this->setTaskInstances($taskInstances);
21
    }
22
23
    /**
24
     * @return ArrayCollection
25
     */
26 1
    public function getTaskInstances(): ArrayCollection
27
    {
28 1
        return $this->taskInstances;
29
    }
30
31
    /**
32
     * @param ArrayCollection $taskInstances
33
     *
34
     * @return JobInstance
35
     */
36 7
    public function setTaskInstances(ArrayCollection $taskInstances): JobInstance
37
    {
38
        $this->taskInstances = $taskInstances->filter(function(TaskInstance $taskInstance) {
1 ignored issue
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
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 7
            return true;
40 7
        });
41 7
        return $this;
42
    }
43
44
    /**
45
     * @param TaskInstance $taskInstance
46
     *
47
     * @return JobInstance
48
     */
49
    public function addTaskInstance(TaskInstance $taskInstance): JobInstance
50
    {
51
        $this->taskInstances[] = $taskInstance;
52
        return $this;
53
    }
54
55
    /**
56
     * @param TaskInstance $taskInstance
57
     *
58
     * @return JobInstance
59
     */
60
    public function removeTaskInstance(TaskInstance $taskInstance): JobInstance
61
    {
62
        $this->taskInstances->removeElement($taskInstance);
63
        return $this;
64
    }
65
}
66