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.

JiraRestApiProvider::register()   B
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 45
Code Lines 25

Duplication

Lines 15
Ratio 33.33 %

Importance

Changes 0
Metric Value
dl 15
loc 45
rs 8.8571
c 0
b 0
f 0
cc 2
eloc 25
nc 1
nop 1
1
<?php
2
3
namespace JiraRestApi\Provider\Silex2;
4
5
use GuzzleHttp\Client;
6
use GuzzleHttp\RequestOptions;
7
use JiraRestApi\Configuration\ArrayConfiguration;
8
use Pimple\Container;
9
use Silex\Application;
10
use Pimple\ServiceProviderInterface;
11
12
class JiraRestApiProvider implements ServiceProviderInterface
13
{
14
    /**
15
     * @param Container $app
16
     */
17
    public function register(Container $app)
18
    {
19
        $app['jira.config'] = [];
20
21 View Code Duplication
        $app['jira.rest.transport'] = function () use ($app) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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
            $cfg = $app['jira.rest.configuration'];
23
24
            return new Client([
25
                'base_uri' => $cfg->getJiraHost(),
26
                RequestOptions::AUTH => [$cfg->getJiraUser(), $cfg->getJiraPassword()]
27
            ]);
28
        };
29
30
        $app['jira.rest.configuration'] = function() use ($app) {
31
            return new ArrayConfiguration($app['jira.config']);
32
        };
33
34 View Code Duplication
        $app['jira.rest.service.builder'] = $app->protect(function($serviceName) use ($app) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
35
            if(class_exists($serviceName)) {
36
                return new $serviceName($app['jira.rest.configuration'], $app['jira.rest.transport'], $app['logger']);
37
            }
38
39
            throw new \Exception('Service ' . $serviceName .' not found');
40
        });
41
42
        $app['jira.rest.issue'] = function() use ($app) {
43
            $className = '\JiraRestApi\Issue\IssueService';
44
            return $app['jira.rest.service.builder']($className);
45
        };
46
47
        $app['jira.rest.issuetype'] = function() use ($app) {
48
            $className = '\JiraRestApi\Issue\IssueTypeService';
49
            return $app['jira.rest.service.builder']($className);
50
        };
51
52
        $app['jira.rest.project'] = function() use ($app) {
53
            $className = '\JiraRestApi\Project\ProjectService';
54
            return $app['jira.rest.service.builder']($className);
55
        };
56
57
        $app['jira.rest.webhook'] = function() use ($app) {
58
            $className = '\JiraRestApi\Webhook\WebhookService';
59
            return $app['jira.rest.service.builder']($className);
60
        };
61
    }
62
}