Completed
Push — master ( bd4c23...b341c0 )
by Filipe
10:29
created

FullUrlTransformerSpec::getMatchers()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 22
Code Lines 12

Duplication

Lines 22
Ratio 100 %

Importance

Changes 0
Metric Value
dl 22
loc 22
rs 9.2
c 0
b 0
f 0
cc 3
eloc 12
nc 1
nop 0
1
<?php
2
3
namespace spec\Slick\Mvc\Service\UriGenerator\Transformer;
4
5
use PhpSpec\Exception\Example\FailureException;
6
use Psr\Http\Message\UriInterface;
7
use Slick\Mvc\Service\UriGenerator\LocationTransformerInterface;
8
use Slick\Mvc\Service\UriGenerator\Transformer\FullUrlTransformer;
9
use PhpSpec\ObjectBehavior;
10
use Prophecy\Argument;
11
12
class FullUrlTransformerSpec extends ObjectBehavior
13
{
14
    function it_is_initializable()
15
    {
16
        $this->shouldHaveType(FullUrlTransformer::class);
17
    }
18
19
    function its_a_location_transformer()
20
    {
21
        $this->shouldBeAnInstanceOf(LocationTransformerInterface::class);
22
    }
23
24
    function it_returns_the_passed_location_when_its_a_full_URL()
25
    {
26
        $this->transform('http://test.com/path')
27
            ->shouldBeAnUriLike('http://test.com/path');
28
    }
29
30 View Code Duplication
    public function getMatchers()
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...
31
    {
32
        return [
33
            'beAnUriLike' => function ($uri, $path)
34
            {
35
                if (!$uri instanceof UriInterface) {
36
                    $class = UriInterface::class;
37
                    $type = gettype($uri);
38
                    throw new FailureException(
39
                        "Expected {$class} instance, but got '{$type}'"
40
                    );
41
                }
42
43
                if ($uri->__toString() !== $path) {
44
                    throw new FailureException(
45
                        "Expected URI with path '{$path}', but got '{$uri}'"
46
                    );
47
                }
48
                return true;
49
            }
50
        ];
51
    }
52
}
53