Passed
Pull Request — master (#247)
by Gonçalo
01:40
created

BoardService   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 59
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getBoardList() 0 8 1
A getBoardIssues() 0 8 1
A __construct() 0 4 1
A getBoard() 0 8 1
A getBoardSprints() 0 10 1
1
<?php
2
3
namespace JiraRestApi\Board;
4
5
use JiraRestApi\Configuration\ConfigurationInterface;
6
use JiraRestApi\Issue\Issue;
7
use JiraRestApi\Sprint\Sprint;
8
use Psr\Log\LoggerInterface;
9
10
class BoardService extends \JiraRestApi\JiraClient
11
{
12
    private $uri = '/board';
13
14
    public function __construct(ConfigurationInterface $configuration = null, LoggerInterface $logger = null, $path = './')
15
    {
16
        parent::__construct($configuration, $logger, $path);
17
        $this->setAPIUri('/rest/agile/1.0');
18
    }
19
20
    /**
21
     * get all boards list.
22
     *
23
     * @param array $paramArray
24
     *
25
     * @throws \JiraRestApi\JiraException
26
     *
27
     * @return Board[] array of Board class
28
     */
29
    public function getBoardList($paramArray = [])
30
    {
31
        $json = $this->exec($this->uri.$this->toHttpQueryParameter($paramArray), null);
32
        $boards = $this->json_mapper->mapArray(
33
            json_decode($json)->values, new \ArrayObject(), Board::class
34
        );
35
36
        return $boards;
37
    }
38
39
    public function getBoard($id, $paramArray = [])
40
    {
41
        $json = $this->exec($this->uri.'/'.$id.$this->toHttpQueryParameter($paramArray), null);
42
        $board = $this->json_mapper->map(
43
            json_decode($json), new Board()
44
        );
45
46
        return $board;
47
    }
48
49
    public function getBoardIssues($id, $paramArray = [])
50
    {
51
        $json = $this->exec($this->uri.'/'.$id.'/issue'.$this->toHttpQueryParameter($paramArray), null);
52
        $issues = $this->json_mapper->mapArray(
53
            json_decode($json)->issues, new \ArrayObject(), Issue::class
54
        );
55
56
        return $issues;
57
    }
58
59
    public function getBoardSprints($boardId, $paramArray = [])
60
    {
61
        $json = $this->exec($this->uri.'/'.$boardId.'/sprint'.$this->toHttpQueryParameter($paramArray), null);
62
        $sprints = $this->json_mapper->mapArray(
63
            json_decode($json)->values,
64
            new \ArrayObject(),
65
            Sprint::class
66
        );
67
68
        return $sprints;
69
    }
70
}
71