Test Failed
Push — master ( c6b6d3...528954 )
by Dan Michael O.
03:21
created

LibrariesSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 60 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 24
loc 40
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 3

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_muh() 0 6 1
A it_provides_a_lazy_interface_to_libary_objects() 10 10 1
A it_provides_libraries() 14 14 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 spec\Scriptotek\Alma\Conf;
4
5
use Psr\Http\Message\UriInterface;
6
use Scriptotek\Alma\Client as AlmaClient;
7
use Scriptotek\Alma\Conf\Libraries;
8
use Scriptotek\Alma\Conf\Library;
9
use PhpSpec\ObjectBehavior;
10
use spec\Scriptotek\Alma\SpecHelper;
11
12
class LibrariesSpec extends ObjectBehavior
13
{
14
    public function let(AlmaClient $client)
15
    {
16
        $this->beConstructedWith($client);
17
    }
18
19
    function it_is_muh()
20
    {
21
        $this->shouldBeAnInstanceOf(Libraries::class);
22
        $this->shouldImplement(\Countable::class);
23
        $this->shouldImplement(\Iterator::class);
24
    }
25
26 View Code Duplication
    function it_provides_a_lazy_interface_to_libary_objects(AlmaClient $client)
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...
27
    {
28
        SpecHelper::expectNoRequests($client);
29
30
        $libraryCode = 'THAT_LIBRARY';
31
        $library = $this->get($libraryCode);
32
33
        $library->shouldBeAnInstanceOf(Library::class);
34
        $library->code->shouldBe($libraryCode);
35
    }
36
37 View Code Duplication
    function it_provides_libraries(AlmaClient $client, UriInterface $url)
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...
38
    {
39
        $client->buildUrl('/conf/libraries', [])
40
            ->shouldBeCalled()
41
            ->willReturn($url);
42
43
        $client->getJSON($url)
44
            ->shouldBeCalled()
45
            ->willReturn(SpecHelper::getDummyData('libraries_response.json'));
46
47
        $this->shouldHaveCount(27);
48
        $this->all()->shouldBeArray();
49
        $this->all()[0]->shouldBeAnInstanceOf(Library::class);
50
    }
51
}
52