Completed
Push — master ( 8367d0...2dd189 )
by Andrew
02:19
created

DisableTransporters   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 9
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A whenWarpDriveIsEngaged() 0 6 1
1
<?php require_once __DIR__ . '/vendor/autoload.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 3 and the first side effect is on line 1.

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
final class WarpDriveEngaged
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    private $speed;
6
7
    public function __construct($speed)
8
    {
9
        $this->speed = $speed;
10
    }
11
12
    public function getSpeed()
13
    {
14
        return $this->speed;
15
    }
16
}
17
18
final class DisableTransporters
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
19
{
20
    public function whenWarpDriveIsEngaged(WarpDriveEngaged $event)
21
    {
22
        var_dump($event);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($event); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
23
24
        echo "Disabling Transporters!\n";
25
    }
26
}
27
28
final class NewInstanceListenerLocator implements \Cairns\Radiate\Locator\ListenerLocator {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
29
    public function locate($fqcn) {
30
        return new $fqcn;
31
    }
32
}
33
34
$registry = new \Cairns\Radiate\Registry\TypehintedClassRegistry;
35
$registry->register(DisableTransporters::class);
36
37
$invoker = new \Cairns\Radiate\Middleware\InvokeListenerMiddleware(
38
    $registry,
39
    new NewInstanceListenerLocator,
40
    new Cairns\Radiate\Inflector\TypehintMethodInflector
41
);
42
43
$emitter = new Cairns\Radiate\Emitter([
44
    $invoker
45
]);
46
47
$emitter->emit(new WarpDriveEngaged(9));
48