Passed
Pull Request — master (#28)
by Valentin
04:39
created

ListSchedulesCommand   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 11
c 1
b 0
f 0
dl 0
loc 44
ccs 14
cts 14
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A parseResponse() 0 10 2
A __construct() 0 2 1
A getAction() 0 3 1
A getResponseParser() 0 3 1
A getGroup() 0 3 1
1
<?php
2
3
namespace Pheanstalk\Command;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Pheanstalk\ResponseParser;
7
use Pheanstalk\Structure\Workflow;
8
9
/**
10
 * The 'ListSchedulesCommand' command.
11
 *
12
 * List workflow schedules .
13
 *
14
 *
15
 * @author  Valentin Corre
16
 * @package Pheanstalk
17
 * @license http://www.opensource.org/licenses/mit-license.php
18
 */
19
class ListSchedulesCommand extends GetScheduleCommand implements ResponseParser
20
{
21
22
    public function __construct()
23
    {
24
    }
25
26
    /**
27
     * @inheritDoc
28
     */
29 1
    public function getGroup(): string
30
    {
31 1
        return 'workflow_schedules';
32
    }
33
34
    /**
35
     * @inheritDoc
36
     */
37 1
    public function getAction(): string
38
    {
39 1
        return 'list';
40
    }
41
42
    /**
43
     * @inheritDoc
44
     */
45 1
    public function getResponseParser()
46
    {
47 1
        return $this;
48
    }
49
50
    /**
51
     * @inheritDoc
52
     */
53 1
    public function parseResponse($responseLine, $responseData)
54
    {
55 1
        $schedules = [];
56 1
        foreach ($responseData['workflow_schedule'] as $scheduleDatas) {
57 1
            $scheduleDatas = $scheduleDatas['@attributes'] ?? $scheduleDatas;
58 1
            $this->scheduleId = $scheduleDatas['id'];
59 1
            $schedule = $this->createScheduleFromArray($scheduleDatas);
60 1
            $schedules[] = $schedule;
61
        }
62 1
        return new ArrayCollection($schedules);
63
    }
64
}
65