Completed
Push — master ( 72cf7f...51e3a2 )
by KwangSeob
02:25
created

PriorityService::getAll()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 0
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace JiraRestApi\Priority;
4
5
use \JiraRestApi\Issue\Priority;
6
7
/**
8
 * Class to query priority.
9
 */
10
class PriorityService extends \JiraRestApi\JiraClient
11
{
12
    private $uri = '/priority';
13
14
    /**
15
     * Function to get all priorities.
16
     *
17
     * @throws \JiraRestApi\JiraException
18
     * @throws \JsonMapper_Exception
19
     *
20
     * @return Priority|object Priority class
21
     */
22
    public function getAll()
23
    {
24
        $ret = $this->exec($this->uri, null);
25
26
        $this->log->addInfo("Result=\n".$ret);
27
28
        $priorityData = json_decode($ret);
29
        $priorities = [];
30
31
        foreach ($priorityData as $priority) {
32
            $priorities[] = $this->json_mapper->map($priority, new Priority());
33
        }
34
35
        return $priorities;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $priorities returns the type array|array<mixed,object> which is incompatible with the documented return type object|JiraRestApi\Issue\Priority.
Loading history...
36
    }
37
38
    /**
39
     *  get specific priority info
40
     *
41
     * @param $priorityId priority id
42
     * @return \JiraRestApi\Priority\Priority
43
     *
44
     * @throws \JiraRestApi\JiraException
45
     * @throws \JsonMapper_Exception
46
     */
47
    public function get($priorityId)
48
    {
49
        $ret = $this->exec($this->uri."/$priorityId", null);
50
51
        $this->log->addInfo("Result=\n".$ret);
52
53
        $priority = $this->json_mapper->map(json_decode($ret), new Priority());
54
55
        return $priority;
56
57
    }
58
}
59