ConfigTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A test() 0 22 1
1
<?php
2
3
namespace Test;
4
5
use Basis\Config;
6
use Basis\Test;
7
8
class ConfigTest extends Test
9
{
10
    public function test()
11
    {
12
        $config = $this->app->get(Config::class);
13
        $this->assertInstanceOf(Config::class, $config);
14
15
        $this->assertSame($config, $this->app->get(Config::class));
16
17
        $this->assertSame($config['service'], 'test');
18
        $this->assertSame($config['environment'], 'testing');
19
        $this->assertSame($config['tarantool.connection'], getenv('TARANTOOL_CONNECTION'));
20
        $this->assertCount(4, get_object_vars($config));
0 ignored issues
show
Documentation introduced by
get_object_vars($config) 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...
21
22
        $this->assertArrayHasKey('service', $config);
23
24
        $config['custom.property'] = true;
25
        $this->assertArrayHasKey('custom', $config);
26
        $this->assertArrayHasKey('custom.property', $config);
27
28
        unset($config['custom']);
29
        $this->assertNull($config['custom']);
30
        $this->assertNull($config['custom.property']);
31
    }
32
}
33