ListInProgressCommand::getResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 1
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Copyright © 2017 Toan Nguyen. All rights reserved.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Gojira\Command\Jira\Issues;
10
11
use Gojira\Api\Request\StatusCodes;
12
use Gojira\Command\Jira\AbstractCommand;
13
use Gojira\Jira\Endpoint\JqlEndpoint;
14
use Gojira\Jira\Response\JqlResponse;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
/**
19
 * Show list issues command (issue:list:in-progress)
20
 *
21
 * @package Gojira\Command\Jira
22
 * @author  Toan Nguyen <[email protected]>
23
 */
24
class ListInProgressCommand extends AbstractCommand
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    protected function configure()
30
    {
31
        $this
32
            ->setName('issue:list:in-progress')
33
            ->setAliases(['running'])
34
            ->setDescription('Show list of issues in progress');
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    protected function execute(InputInterface $input, OutputInterface $output)
41
    {
42
        if ($this->authentication->isAuth()) {
43
            $this->doExecute(
44
                $output,
45
                StatusCodes::HTTP_OK,
46
                [],
47
                ['Key', 'Priority', 'Summary', 'Status']
48
            );
49
        }
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    protected function getResponse($filters = [])
56
    {
57
        $jqlQuery = __(
58
            '%1%2%3',
59
            'assignee=currentUser()',
60
            '+AND+status+in+("In Progress")',
61
            '+order+by+priority+DESC,+key+ASC'
62
        );
63
64
        $searchEndpoint = new JqlEndpoint($this->getApiClient());
65
        return $searchEndpoint->search($jqlQuery);
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71
    protected function renderResult($response = [], $type = null)
72
    {
73
        return (new JqlResponse($response))->render($type);
74
    }
75
}
76