Completed
Pull Request — master (#299)
by Alexander
02:00
created

AgileIssueService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
eloc 13
c 1
b 1
f 1
dl 0
loc 25
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 13 2
A __construct() 0 4 1
1
<?php
2
3
namespace JiraRestApi\Issue;
4
5
use JiraRestApi\AgileApiTrait;
6
use JiraRestApi\Configuration\ConfigurationInterface;
7
use Psr\Log\LoggerInterface;
8
9
class AgileIssueService extends \JiraRestApi\JiraClient
10
{
11
    use AgileApiTrait;
12
13
    private $uri = '/issue';
14
15
    public function __construct(ConfigurationInterface $configuration = null, LoggerInterface $logger = null, $path = './')
16
    {
17
        parent::__construct($configuration, $logger, $path);
18
        $this->setupAPIUri();
19
    }
20
21
    public function get($issueIdOrKey, $paramArray = []): ?AgileIssue
22
    {
23
        $response = $this->exec($this->uri.'/'.$issueIdOrKey.$this->toHttpQueryParameter($paramArray), null);
24
25
        try {
26
            return $this->json_mapper->map(
27
                json_decode($response, false, 512, JSON_THROW_ON_ERROR),
28
                new AgileIssue()
29
            );
30
        } catch (\JsonException $exception) {
31
            $this->log->error("Response cannot be decoded from json\nException: {$exception->getMessage()}");
32
33
            return null;
34
        }
35
    }
36
}
37