Passed
Pull Request — master (#345)
by
unknown
02:32
created

StatusService::getAll()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 10
nc 2
nop 0
dl 0
loc 17
rs 9.9332
c 1
b 0
f 1
1
<?php
2
3
4
namespace JiraRestApi\Status;
5
6
7
use JiraRestApi\JiraException;
8
use JsonMapper_Exception;
9
10
class StatusService extends \JiraRestApi\JiraClient
11
{
12
    private $uri = '/status';
13
14
    /**
15
     * get all statuses
16
     * @throws JiraException
17
     * @throws JsonMapper_Exception
18
     *
19
     * @return Status[] array of Project class
20
     */
21
    public function getAll()
22
    {
23
        if ($this->isRestApiV3()) {
24
            throw new JiraException('V3 is currently not supported');
25
        }
26
        else {
27
            $statusObject = new Status();
0 ignored issues
show
Unused Code introduced by
The assignment to $statusObject is dead and can be removed.
Loading history...
28
        }
29
30
        $ret = $this->exec($this->uri.'/', null);
31
        $this->log->info("Result=\n".$ret);
0 ignored issues
show
Bug introduced by
Are you sure $ret of type string|true can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

31
        $this->log->info("Result=\n"./** @scrutinizer ignore-type */ $ret);
Loading history...
32
33
34
        return $this->json_mapper->mapArray(
35
            json_decode($ret, false),
0 ignored issues
show
Bug introduced by
It seems like $ret can also be of type true; however, parameter $json of json_decode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

35
            json_decode(/** @scrutinizer ignore-type */ $ret, false),
Loading history...
36
            new \ArrayObject(),
37
            '\JiraRestApi\Status\status'
38
        );
39
    }
40
41
}