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::register()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 36

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 2.1126

Importance

Changes 0
Metric Value
dl 0
loc 36
ccs 16
cts 23
cp 0.6957
rs 9.344
c 0
b 0
f 0
cc 2
nc 1
nop 1
crap 2.1126
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