Passed
Push — master ( ab8b9d...7e5c9a )
by Valentin
08:11 queued 06:26
created

ListSchedulesCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 2
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
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