Completed
Push — master ( e15c58...b150a8 )
by Changwan
07:08
created

PingCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
ccs 0
cts 5
cp 0
crap 2
rs 9.4285
c 1
b 0
f 0
1
<?php
2
namespace Wandu\Event\Commands;
3
4
use Wandu\Console\Command;
5
use Wandu\Event\Dispatcher;
6
use Wandu\Event\Events\Ping;
7
use Wandu\Q\Queue;
8
9
class PingCommand extends Command
10
{
11
    /** @var string */
12
    protected $description = "Queue a \"Ping\" event for testing";
13
14
    /**
15
     * @param \Wandu\Q\Queue $queue
16
     * @param \Wandu\Event\Dispatcher $dispatcher
17
     */
18
    public function __construct(Queue $queue, Dispatcher $dispatcher)
19
    {
20
        $this->queue = $queue;
0 ignored issues
show
Bug introduced by
The property queue does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
21
        $this->dispatcher = $dispatcher;
0 ignored issues
show
Bug introduced by
The property dispatcher does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
22
    }
23
24
    function execute()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
25
    {
26
        $this->output->writeln("Send Ping Event..");
27
        $this->dispatcher->trigger(new Ping("Ping..."));
28
    }
29
}
30