JobCollection   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 40%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 6 1
A getJobs() 0 4 1
A toArray() 0 11 2
1
<?php
2
3
/**
4
 * Gearman Bundle for Symfony2 / Symfony3
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * Feel free to edit as you please, and have fun.
10
 *
11
 * @author Marc Morera <[email protected]>
12
 */
13
14
namespace Mkk\GearmanBundle\Module;
15
16
use Mkk\GearmanBundle\Module\JobClass as Job;
17
18
/**
19
 * Job Collection class
20
 */
21
class JobCollection
22
{
23
    /**
24
     * @var array
25
     *
26
     * All jobs from worker
27
     */
28
    private $workerJobs = array();
29
30
    /**
31
     * Adds into $workerJobs a Job instance
32
     * Return self object
33
     *
34
     * @param Job $workJob Class to add into array
35
     *
36
     * @return JobCollection
37
     */
38
    public function add(Job $workJob)
39
    {
40
        $this->workerJobs[] = $workJob;
41
42
        return $this;
43
    }
44
45
    /**
46
     * Retrieve all Jobs added previously
47
     *
48
     * @return array
49
     */
50
    public function getJobs()
51
    {
52
        return $this->workerJobs;
53
    }
54
55
    /**
56
     * Retrieve all jobs loaded previously in cache format
57
     *
58
     * @return array
59
     */
60 3
    public function toArray()
61
    {
62 3
        $jobs = array();
63
64 3
        foreach ($this->workerJobs as $job) {
65
66
            $jobs[] = $job->toArray();
67
        }
68
69 3
        return $jobs;
70
    }
71
}
72