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.

StandardServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 8

Test Coverage

Coverage 69.57%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 8
dl 0
loc 42
ccs 16
cts 23
cp 0.6957
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 36 2
1
<?php declare(strict_types=1);
2
/**
3
 * Starlit App.
4
 *
5
 * @copyright Copyright (c) 2016 Starweb AB
6
 * @license   BSD 3-Clause
7
 */
8
9
namespace Starlit\App\Provider;
10
11
use Starlit\App\BaseApp;
12
use Starlit\App\Router;
13
use Starlit\App\RouterInterface;
14
use Starlit\App\View;
15
use Starlit\App\ViewInterface;
16
use Symfony\Component\HttpFoundation\Response;
17
use Symfony\Component\HttpFoundation\Session\Session;
18
use Symfony\Component\HttpFoundation\Session\SessionInterface;
19
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
20
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
21
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface;
22
23
class StandardServiceProvider implements ServiceProviderInterface
24
{
25
    /**
26
     * @param BaseApp $app
27
     */
28 23
    public function register(BaseApp $app): void
29
    {
30 23
        $app->alias('sessionStorage', SessionStorageInterface::class);
31
        $app->set(SessionStorageInterface::class, function (BaseApp $app) {
32 1
            if ($app->isCli()) {
33 1
                return new MockArraySessionStorage();
34
            }
35
            return new NativeSessionStorage();
36 23
        });
37
38 23
        $app->alias('session', SessionInterface::class);
39 23
        $app->set(SessionInterface::class, Session::class);
40
41 23
        $app->alias('router', RouterInterface::class);
42
        $app->set(RouterInterface::class, function (BaseApp $app) {
43 1
            return new Router($app, $app->getConfig()->get('router', []));
44 23
        });
45
46 23
        $app->alias('view', ViewInterface::class);
47
        $app->set(ViewInterface::class, function (BaseApp $app) {
48 3
            return new View($app->getConfig()->get('view', []));
49 23
        });
50
51
        // Default response (force no cache)
52 23
        $app->alias('response', Response::class);
53
        $app->set(Response::class, function () {
54
            $response = new Response();
55
56
            $response->headers->addCacheControlDirective('no-cache', true);
57
            $response->headers->addCacheControlDirective('max-age', 0);
58
            $response->headers->addCacheControlDirective('must-revalidate', true);
59
            $response->headers->addCacheControlDirective('no-store', true);
60
61
            return $response;
62 23
        });
63 23
    }
64
}
65