Completed
Branch master (df0330)
by Gabriel
08:50 queued 06:43
created

LiteralTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 50 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testAssemble() 12 12 1
A testMatch() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Nip\Router\Tests\Parsers;
4
5
use Nip\Router\Parsers\Literal;
6
7
/**
8
 * Test class for Nip_Route_Abstract.
9
 * Generated by PHPUnit on 2010-11-17 at 15:16:44.
10
 */
11
class LiteralTest extends \Nip\Router\Tests\AbstractTest
12
{
13
14
    /**
15
     * @var Literal
16
     */
17
    protected $object;
18
19
    /**
20
     * Sets up the fixture, for example, opens a network connection.
21
     * This method is called before a test is executed.
22
     */
23
    protected function setUp() : void
24
    {
25
        $this->object = new Literal();
26
    }
27
28 View Code Duplication
    public function testAssemble()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
    {
30
        $params = [
31
            'url' => 'lorem',
32
            'name' => 'ipsum',
33
            'company' => 'dolo&rem',
34
        ];
35
        static::assertEquals('?url=lorem&name=ipsum&company=dolo%26rem', $this->object->assemble($params));
36
37
        $this->object->setMap('shop/cart');
0 ignored issues
show
Documentation introduced by
'shop/cart' is of type string, but the function expects a boolean.

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...
38
        static::assertEquals('shop/cart?url=lorem&name=ipsum&company=dolo%26rem', $this->object->assemble($params));
39
    }
40
41 View Code Duplication
    public function testMatch()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
42
    {
43
        $map = 'shop/cart';
44
        $this->object->setMap($map);
0 ignored issues
show
Documentation introduced by
$map is of type string, but the function expects a boolean.

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...
45
        static::assertFalse($this->object->match('shop/category_cast/'));
46
        static::assertTrue($this->object->match('shop/cart'));
47
    }
48
}
49