Crap   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 2
cbo 2
dl 0
loc 46
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getHelp() 0 4 1
A run() 0 9 1
1
<?php
2
3
namespace Geekish\Crap;
4
5
use Symfony\Component\Console\Application;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
/**
10
 * Class Crap
11
 * @package Geekish\Crap
12
 * @codeCoverageIgnore
13
 */
14
final class Crap extends Application
15
{
16
    const FILENAME = 'crap.json';
17
18
    /**
19
     * Crap application version
20
     * @var string
21
     */
22
    const VERSION = '1.0.0';
23
24
    private static $logo = '   __________  ___    ____
25
  / ____/ __ \/   |  / __ \
26
 / /   / /_/ / /| | / /_/ /
27
/ /___/ _, _/ ___ |/ ____/
28
\____/_/ |_/_/  |_/_/
29
';
30
31
    /**
32
     * Crap Constructor
33
     */
34
    public function __construct()
35
    {
36
        parent::__construct('crap', self::VERSION);
37
    }
38
39
    /**
40
     * @inheritDoc
41
     */
42
    public function getHelp()
43
    {
44
        return self::$logo . parent::getHelp();
45
    }
46
47
    /**
48
     * @inheritDoc
49
     */
50
    public function run(InputInterface $input = null, OutputInterface $output = null)
51
    {
52
        $this->setCatchExceptions(false);
53
        $this->setAutoExit(false);
54
55
        set_exception_handler(new ExceptionHandler($output));
0 ignored issues
show
Bug introduced by
It seems like $output defined by parameter $output on line 50 can be null; however, Geekish\Crap\ExceptionHandler::__construct() does not accept null, maybe add an additional type check?

It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.

We recommend to add an additional type check (or disallow null for the parameter):

function notNullable(stdClass $x) { }

// Unsafe
function withoutCheck(stdClass $x = null) {
    notNullable($x);
}

// Safe - Alternative 1: Adding Additional Type-Check
function withCheck(stdClass $x = null) {
    if ($x instanceof stdClass) {
        notNullable($x);
    }
}

// Safe - Alternative 2: Changing Parameter
function withNonNullableParam(stdClass $x) {
    notNullable($x);
}
Loading history...
56
57
        return $this->doRun($input, $output);
0 ignored issues
show
Bug introduced by
It seems like $input defined by parameter $input on line 50 can be null; however, Symfony\Component\Console\Application::doRun() does not accept null, maybe add an additional type check?

It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.

We recommend to add an additional type check (or disallow null for the parameter):

function notNullable(stdClass $x) { }

// Unsafe
function withoutCheck(stdClass $x = null) {
    notNullable($x);
}

// Safe - Alternative 1: Adding Additional Type-Check
function withCheck(stdClass $x = null) {
    if ($x instanceof stdClass) {
        notNullable($x);
    }
}

// Safe - Alternative 2: Changing Parameter
function withNonNullableParam(stdClass $x) {
    notNullable($x);
}
Loading history...
Bug introduced by
It seems like $output defined by parameter $output on line 50 can be null; however, Symfony\Component\Console\Application::doRun() does not accept null, maybe add an additional type check?

It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.

We recommend to add an additional type check (or disallow null for the parameter):

function notNullable(stdClass $x) { }

// Unsafe
function withoutCheck(stdClass $x = null) {
    notNullable($x);
}

// Safe - Alternative 1: Adding Additional Type-Check
function withCheck(stdClass $x = null) {
    if ($x instanceof stdClass) {
        notNullable($x);
    }
}

// Safe - Alternative 2: Changing Parameter
function withNonNullableParam(stdClass $x) {
    notNullable($x);
}
Loading history...
58
    }
59
}
60