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.
Completed
Push — v0 ( e38f63...c79c1c )
by Jason
03:46 queued 01:45
created

OptionsController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 78.56%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 4
dl 0
loc 26
ccs 11
cts 14
cp 0.7856
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B __invoke() 0 23 4
1
<?php
2
3
namespace JDesrosiers\Silex\Provider;
4
5
use Silex\Application;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
9
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
10
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
11
12
class OptionsController
13
{
14 10
    public function __invoke(Application $app, Request $request)
15
    {
16 10
        $app["request_context"]->setMethod("NOTAMETHOD");
17
18
        try {
19 10
            $app["url_matcher"]->match($request->getPathInfo());
20
            $allow = []; // Should never get here
21 10
        } catch (MethodNotAllowedException $e) {
22 10
            $allow = array_filter($e->getAllowedMethods(), function ($method) {
23 10
                return $method != "OPTIONS";
24 10
            });
25
        } catch (ResourceNotFoundException $e) {
26
            $allow = []; // Should never get here
27
        }
28
29 10
        $app["request_context"]->setMethod("OPTIONS");
30
31 10
        if (count($allow) == 0) {
32 1
            throw new NotFoundHttpException();
33
        }
34
35 9
        return Response::create("", 204, ["Allow" => implode(",", $allow)]);
36
    }
37
}
38