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\Silex1;
4
5
use GuzzleHttp\Client;
6
use GuzzleHttp\RequestOptions;
7
use JiraRestApi\Configuration\ArrayConfiguration;
8
use Silex\Application;
9
use Silex\ServiceProviderInterface;
10
11
class JiraRestApiProvider implements ServiceProviderInterface
12
{
13
    /**
14
     * @param Application $app
15
     */
16
    public function register(Application $app)
17
    {
18
        $app['jira.config'] = [];
19
20 View Code Duplication
        $app['jira.rest.transport'] = $app->share(function () use ($app) {
0 ignored issues
show
Bug introduced by
The method share() does not seem to exist on object<Silex\Application>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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...
21
            $cfg = $app['jira.rest.configuration'];
22
23
            return new Client([
24
                'base_uri' => $cfg->getJiraHost(),
25
                RequestOptions::AUTH => [$cfg->getJiraUser(), $cfg->getJiraPassword()]
26
            ]);
27
        });
28
29
        $app['jira.rest.configuration'] = $app->share(function() use ($app) {
0 ignored issues
show
Bug introduced by
The method share() does not seem to exist on object<Silex\Application>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
30
            return new ArrayConfiguration($app['jira.config']);
31
        });
32
33 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...
34
            if(class_exists($serviceName)) {
35
                return new $serviceName($app['jira.rest.configuration'], $app['jira.rest.transport'], $app['logger']);
36
            }
37
38
            throw new \Exception('Service ' . $serviceName .' not found');
39
        });
40
41
        $app['jira.rest.issue'] = $app->share(function() use ($app) {
0 ignored issues
show
Bug introduced by
The method share() does not seem to exist on object<Silex\Application>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
42
            $className = '\JiraRestApi\Issue\IssueService';
43
            return $app['jira.rest.service.builder']($className);
44
        });
45
46
        $app['jira.rest.issuetype'] = $app->share(function() use ($app) {
0 ignored issues
show
Bug introduced by
The method share() does not seem to exist on object<Silex\Application>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
            $className = '\JiraRestApi\Issue\IssueTypeService';
48
            return $app['jira.rest.service.builder']($className);
49
        });
50
51
        $app['jira.rest.project'] = $app->share(function() use ($app) {
0 ignored issues
show
Bug introduced by
The method share() does not seem to exist on object<Silex\Application>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
52
            $className = '\JiraRestApi\Project\ProjectService';
53
            return $app['jira.rest.service.builder']($className);
54
        });
55
56
        $app['jira.rest.webhook'] = $app->share(function() use ($app) {
0 ignored issues
show
Bug introduced by
The method share() does not seem to exist on object<Silex\Application>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
            $className = '\JiraRestApi\Webhook\WebhookService';
58
            return $app['jira.rest.service.builder']($className);
59
        });
60
    }
61
62
    /**
63
     * @param Application $app
64
     */
65
    public function boot(Application $app)
66
    {
67
    }
68
}