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 — master ( 2b8c74...685370 )
by Andreas
03:07
created

ErrorServiceProvider::register()   B

Complexity

Conditions 5
Paths 1

Size

Total Lines 51
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 27
CRAP Score 5.0536

Importance

Changes 0
Metric Value
dl 0
loc 51
ccs 27
cts 31
cp 0.871
rs 8.6588
c 0
b 0
f 0
cc 5
eloc 30
nc 1
nop 1
crap 5.0536

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
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
13
/**
14
 * @author Andreas Nilsson <http://github.com/jandreasn>
15
 */
16
class ErrorServiceProvider implements ServiceProviderInterface
17
{
18
    /**
19
     * @param BaseApp $app
20
     */
21 18
    public function register(BaseApp $app)
22
    {
23
        $app->set('errorLogger', function (BaseApp $app) {
24 18
            $logger = new \Monolog\Logger('errorLogger');
25
26 18
            $handler = new \Monolog\Handler\ErrorLogHandler();
27 18
            if (!$app->isCli()) {
28
                $handler->pushProcessor(new \Monolog\Processor\WebProcessor());
29
                $format = '%level_name%: %message% %extra.server%%extra.url%';
30
            } else {
31 18
                $format = '%level_name%: %message%';
32
            }
33 18
            $handler->setFormatter(new \Monolog\Formatter\LineFormatter($format, null, true));
34 18
            $logger->pushHandler($handler);
35
36 18
            return $logger;
37 18
        });
38
39
        $app->set('whoopsDebugErrorPageHandler', function (BaseApp $app) {
40 18
            $prettyPageHandler = new \Whoops\Handler\PrettyPageHandler();
41 18
            if ($app->getConfig()->has('editor')) {
42
                $prettyPageHandler->setEditor($app->getConfig()->get('editor'));
0 ignored issues
show
Documentation introduced by
$app->getConfig()->get('editor') is of type *, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
43
            }
44
45 18
            return $prettyPageHandler;
46 18
        });
47
48
        $app->set('whoopsErrorHandler', function (BaseApp $app) {
49 18
            $plainTextHandler = new \Whoops\Handler\PlainTextHandler();
50 18
            $plainTextHandler->setLogger($app->get('errorLogger'));
51 18
            if (!$app->isCli()) {
52
                $plainTextHandler->loggerOnly(true);
53
            }
54
55 18
            return $plainTextHandler;
56 18
        });
57
58 18
        $app->set('whoops', function (BaseApp $app) {
59 18
            $whoops = new \Whoops\Run();
60
61 18
            if (ini_get('display_errors')) {
62 18
                $whoops->pushHandler($app->get('whoopsDebugErrorPageHandler'));
0 ignored issues
show
Documentation introduced by
$app->get('whoopsDebugErrorPageHandler') is of type *, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
63
            }
64
65
            // Handles cli output and logging
66 18
            $whoops->pushHandler($app->get('whoopsErrorHandler'));
0 ignored issues
show
Documentation introduced by
$app->get('whoopsErrorHandler') is of type *, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
67
68 18
            return $whoops;
69 18
        });
70 18
        $app->get('whoops')->register();
71 18
    }
72
}
73