Completed
Push — master ( 355f41...200862 )
by Mickael
06:25
created

WorkerCollection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 40
ccs 4
cts 8
cp 0.5
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 6 1
A toArray() 0 10 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\WorkerClass as Worker;
17
18
/**
19
 * WorkerCollection class
20
 */
21
class WorkerCollection
22
{
23
    /**
24
     * All Workers
25
     *
26
     * @var array
27
     */
28
    private $workerClasses = array();
29
30
    /**
31
     * Adds a Worker into $workerClasses
32
     * Return self object
33
     *
34
     * @param Worker $workerClass Worker element to add
35
     *
36
     * @return WorkerCollection
37
     */
38
    public function add(Worker $workerClass)
39
    {
40
        $this->workerClasses[] = $workerClass;
41
42
        return $this;
43
    }
44
45
    /**
46
     * Retrieve all workers loaded previously in cache format
47
     *
48
     * @return array
49
     */
50 1
    public function toArray()
51
    {
52 1
        $workersDumped = array();
53
54 1
        foreach ($this->workerClasses as $worker) {
55
            $workersDumped[] = $worker->toArray();
56
        }
57
58 1
        return $workersDumped;
59
    }
60
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
61