GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#8)
by
unknown
02:07
created

JobCollection::count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace dmank\gearman;
3
4
class JobCollection implements \Countable
5
{
6
    /**
7
     * @var array
8
     */
9
    private $jobs;
10
11 7
    public function __construct()
12
    {
13 7
        $this->jobs = array();
14 7
    }
15
16
    /**
17
     * @param JobHandlerInterface $job
18
     */
19 5
    public function add(JobHandlerInterface $job)
20
    {
21 5
        $this->jobs[$job->listensToJob()] = $job;
22 5
    }
23
24
    /**
25
     * @param array $jobs
26
     * @return int count of added jobs
27
     */
28 2
    public function addMultipleJobs(array $jobs)
29
    {
30 2
        $count = 0;
31
32 2
        foreach ($jobs as $job) {
33 2
            if (!$job instanceof JobHandlerInterface) {
34 1
                continue;
35
            }
36
37 1
            $this->add($job);
38
39 1
            $count++;
40 2
        }
41
42 2
        return $count;
43
    }
44
45
    /**
46
     * @return JobHandlerInterface[]
47
     */
48 4
    public function getJobs()
49
    {
50 4
        return $this->jobs;
51
    }
52
53
    /**
54
     * @param $jobName
55
     * @return JobHandlerInterface|null
56
     */
57
    public function getJob($jobName)
58
    {
59
        /** @var JobHandlerInterface $job  */
60
        foreach ($this->getJobs() as $job) {
61
            if ($job->listensToJob() === $jobName) {
62
                return $job;
63
            }
64
        }
65
66
        return null;
67
    }
68
69
    /**
70
     * @return int
71
     */
72 7
    public function count()
73
    {
74 7
        return count($this->jobs);
75
    }
76
}
77