Completed
Push — master ( c4223d...e3af10 )
by Nikita
03:25
created

ScriptHandler::defaultCommand()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 23
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 23
rs 9.0856
c 1
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 10 and the first side effect is on line 10.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace Taisiya\CoreBundle\Composer;
4
5
use Composer\EventDispatcher\Event;
6
use Symfony\Component\Finder\Finder;
7
use Symfony\Component\Finder\SplFileInfo;
8
use Taisiya\CoreBundle\App;
9
10
defined('TAISIYA_ROOT') || define('TAISIYA_ROOT', dirname(dirname(__DIR__)));
11
12
class ScriptHandler
13
{
14
    const EVENT_DEFAULT_COMMAND = 'default_command';
15
16
    /**
17
     * @param Event $event
18
     */
19
    final public static function defaultCommand(Event $event): void
20
    {
21
        $app = file_exists(TAISIYA_ROOT.'/bootstrap.php')
0 ignored issues
show
Unused Code introduced by
$app is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
22
            ? require_once TAISIYA_ROOT.'/bootstrap.php':
23
            new App();
24
25
//        /** @var EventDispatcher $dispatcher */
0 ignored issues
show
Unused Code Comprehensibility introduced by
52% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
26
//        $dispatcher = $event->getComposer()->getEventDispatcher();
27
//
28
//        $defaultCommandEvent = new Event(self::EVENT_DEFAULT_COMMAND, ['app' => $app]);
29
//
30
//        /** @var string $subscriberClass */
31
//        foreach (self::getComposerSubscribers() as $subscriberClass) {
32
//            $reflectionClass = new \ReflectionClass($subscriberClass);
33
//            if ($reflectionClass->isSubclassOf(DefaultCommandSubscriberInterface::class)) {
34
//                $dispatcher->addSubscriber(new $subscriberClass());
35
//            }
36
//        }
37
//
38
//        $dispatcher->dispatch(self::EVENT_DEFAULT_COMMAND, $defaultCommandEvent);
39
40
41
    }
42
}
43