Completed
Push — refactor ( fef2f5...a403e4 )
by Bogdan
03:09
created

ObjectMapTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testPutNotAnObjectFails() 0 6 1
A testPutAndGet() 0 10 1
1
<?php declare(strict_types=1);
2
3
4
namespace Pinepain\ObjectMaps\Tests;
5
6
use Pinepain\ObjectMaps\ObjectMap;
7
use PHPUnit\Framework\TestCase;
8
use stdClass;
9
10
11
class ObjectMapTest extends TestCase
12
{
13
    public function testPutNotAnObjectFails()
14
    {
15
        $map = new ObjectMap();
16
17
        $map->put('foo', 'bar');
0 ignored issues
show
Documentation introduced by
'foo' is of type string, but the function expects a 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...
Documentation introduced by
'bar' is of type string, but the function expects a 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...
18
    }
19
20
    public function testPutAndGet()
21
    {
22
        $map = new ObjectMap();
23
24
        $key   = new stdClass();
25
        $value = new stdClass();
26
27
        $map->put($key, $value);
28
        $this->assertSame($value, $map->get($key));
29
    }
30
}
31