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   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 76%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 1
dl 0
loc 73
ccs 19
cts 25
cp 0.76
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A add() 0 4 1
A addMultipleJobs() 0 16 3
A getJobs() 0 4 1
A getJob() 0 11 3
A count() 0 4 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