Passed
Push — master ( b5424d...ff2040 )
by KwangSeob
02:41 queued 13s
created

SprintService::getSprintIssues()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 2
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: meshulam
5
 * Date: 11/08/2017
6
 * Time: 17:28.
7
 */
8
9
namespace JiraRestApi\Sprint;
10
11
use JiraRestApi\Configuration\ConfigurationInterface;
12
use JiraRestApi\Issue\Issue;
13
use JiraRestApi\JiraClient;
14
use JiraRestApi\JiraException;
15
use Psr\Log\LoggerInterface;
16
17
class SprintService extends JiraClient
18
{
19
    //https://jira01.devtools.intel.com/rest/agile/1.0/board?projectKeyOrId=34012
20
    private $uri = '/sprint';
21
22
    public function __construct(ConfigurationInterface $configuration = null, LoggerInterface $logger = null, $path = './')
23
    {
24
        parent::__construct($configuration, $logger, $path);
25
        $this->setAPIUri('/rest/agile/1.0');
26
    }
27
28
    public function getSprintFromJSON($json)
29
    {
30
        $sprint = $this->json_mapper->map(
31
            $json, new Sprint()
32
        );
33
34
        return $sprint;
35
    }
36
37
    /**
38
     *  get all Sprint list.
39
     *
40
     * @param Sprint $sprintObject
41
     *
42
     * @throws JiraException
43
     * @throws \JsonMapper_Exception
44
     *
45
     * @return object
46
     */
47
    public function getSprint($sprintId)
48
    {
49
        $ret = $this->exec($this->uri.'/'.$sprintId, null);
50
51
        $this->log->info("Result=\n".$ret);
52
53
        return $sprint = $this->json_mapper->map(
0 ignored issues
show
Unused Code introduced by
The assignment to $sprint is dead and can be removed.
Loading history...
54
            json_decode($ret), new Sprint()
55
        );
56
    }
57
58
    public function getSprintIssues($sprintId, $paramArray = [])
59
    {
60
        $json = $this->exec($this->uri.'/'.$sprintId.'/issue'.$this->toHttpQueryParameter($paramArray), null);
61
62
        $issues = $this->json_mapper->mapArray(
63
            json_decode($json)->issues,
64
            new \ArrayObject(),
65
            Issue::class
66
        );
67
68
        return $issues;
69
    }
70
}
71