GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

WebhookService::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace JiraRestApi\Webhook;
4
5
use JiraRestApi\JiraClient;
6
use Symfony\Component\HttpFoundation\Request;
7
8
/**
9
 * Class WebhookService
10
 * @package JiraRestApi\Webhook
11
 */
12
class WebhookService extends JiraClient
13
{
14
    protected $api_uri = '/rest/webhooks/1.0';
15
    private $uri = '/webhook';
16
17
    /**
18
     * get all project list.
19
     * @return bool|mixed
20
     */
21 View Code Duplication
    public function getAllWebhooks()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
    {
23
        $result = $this->exec($this->uri);
24
25
        return $this->extractErrors($result, [200], function () use ($result) {
26
            return $this->json_mapper->mapArray(
27
                $result->getRawData(), new \ArrayObject(), '\JiraRestApi\Webhook\Webhook'
28
            );
29
        });
30
    }
31
32
    /**
33
     * @param $webhookId
34
     *
35
     * @return bool|object
36
     * @throws \JsonMapper_Exception
37
     */
38 View Code Duplication
    public function get($webhookId)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
    {
40
        $result = $this->exec($this->uri . '/' . $webhookId);
41
42
        return $this->extractErrors($result, [200], function () use ($result) {
43
            return $this->json_mapper->map(
44
                $result->getRawData(), new Webhook()
45
            );
46
        });
47
    }
48
49
    /**
50
     * @param Webhook $webhook
51
     *
52
     * @return mixed
53
     */
54
    public function create(Webhook $webhook)
55
    {
56
        $data = $this->filterNullVariable($webhook);
57
58
        $result = $this->exec($this->uri, $data, Request::METHOD_POST);
59
60
        return $this->extractErrors($result, [201], function () use ($result) {
61
            return $this->json_mapper->map(
62
                $result->getRawData(), new Webhook()
63
            );
64
        });
65
    }
66
67
    /**
68
     * @param $webhookId
69
     *
70
     * @return mixed
71
     */
72
    public function delete($webhookId)
73
    {
74
        $result = $this->exec($this->uri . '/' . $webhookId, null, Request::METHOD_DELETE);
75
76
        return $this->extractErrors($result, [204], function () use ($result) {
77
            return $result;
78
        });
79
    }
80
}
81
82