BootstrapTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test() 0 18 1
A registration() 0 4 1
A subscription() 0 4 1
1
<?php
2
3
namespace Test;
4
5
use Basis\Test;
6
use Basis\Filesystem;
7
8
class BootstrapTest extends Test
9
{
10
    public $mocks = [
11
        ['event.subscribe', [], 'subscription'],
12
        ['web.register', [], 'registration'],
13
    ];
14
15
    public function test()
16
    {
17
        $this->assertCount(0, $this->subscriptions);
0 ignored issues
show
Documentation introduced by
$this->subscriptions is of type array, but the function expects a object<Countable>|object...nit\Framework\iterable>.

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...
18
        $this->assertCount(0, $this->registrations);
0 ignored issues
show
Documentation introduced by
$this->registrations is of type array, but the function expects a object<Countable>|object...nit\Framework\iterable>.

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...
19
        $result = $this->dispatch('module.bootstrap');
0 ignored issues
show
Unused Code introduced by
$result 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...
20
21
        // web.register was called
22
        $this->assertCount(1, $this->registrations);
0 ignored issues
show
Documentation introduced by
$this->registrations is of type array, but the function expects a object<Countable>|object...nit\Framework\iterable>.

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...
23
24
        // event.subscribe was called
25
        $this->assertCount(2, $this->subscriptions);
0 ignored issues
show
Documentation introduced by
$this->subscriptions is of type array, but the function expects a object<Countable>|object...nit\Framework\iterable>.

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...
26
        $this->assertSame($this->subscriptions[0]->event, 'person.created');
27
        $this->assertSame($this->subscriptions[1]->event, 'person.person.*');
28
        $this->assertSame($this->subscriptions[0]->service, 'test');
29
30
        // cache exists
31
        $this->dispatch('module.bootstrap');
32
    }
33
34
35
    private $registrations = [];
36
    public function registration($params)
37
    {
38
        $this->registrations[] = $params;
39
    }
40
41
    private $subscriptions = [];
42
    public function subscription($params)
43
    {
44
        $this->subscriptions[] = $params;
45
    }
46
}
47