WorkerCollection::toArray()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 4
cts 5
cp 0.8
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2.032
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 3
    public function toArray()
51
    {
52 3
        $workersDumped = array();
53
54 3
        foreach ($this->workerClasses as $worker) {
55
            $workersDumped[] = $worker->toArray();
56
        }
57
58 3
        return $workersDumped;
59
    }
60
}
61