Completed
Push — master ( 7c9586...c8ce39 )
by Oscar
01:44
created

Delete::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace SimpleCrud\Query;
5
6
use SimpleCrud\Events\CreateDeleteQuery;
7
use SimpleCrud\Table;
8
9
final class Delete implements QueryInterface
10
{
11
    use Traits\Common;
12
    use Traits\HasRelatedWith;
13
14
    private $allowedMethods = [
15
        'setFlag',
16
        'where',
17
        'orWhere',
18
        'catWhere',
19
        'orderBy',
20
        'limit',
21
        'offset',
22
    ];
23
24
    public function __construct(Table $table)
25
    {
26
        $this->table = $table;
27
28
        $this->query = $table->getDatabase()
29
            ->delete()
30
            ->from((string) $table);
31
32
        $eventDispatcher = $table->getEventDispatcher();
33
34
        if ($eventDispatcher) {
35
            $eventDispatcher->dispatch(new CreateDeleteQuery($this));
0 ignored issues
show
Documentation introduced by
new \SimpleCrud\Events\CreateDeleteQuery($this) is of type object<SimpleCrud\Events\CreateDeleteQuery>, but the function expects a object<Psr\EventDispatcher\object>.

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...
36
        }
37
    }
38
}
39