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

WorkerCollection::toArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

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.4285
c 0
b 0
f 0
cc 2
eloc 5
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 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