Completed
Push — master ( 804c7f...1d2ba7 )
by Dan Michael O.
01:59
created

RepresentationsSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 5 5 1
A it_is_initializable() 4 4 1
A expectRequest() 6 6 1
A it_is_countable() 6 6 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\Bibs;
4
5
use Scriptotek\Alma\Bibs\Bib;
6
use Scriptotek\Alma\Bibs\Representations;
7
use Scriptotek\Alma\Client as AlmaClient;
8
use PhpSpec\ObjectBehavior;
9
use Prophecy\Argument;
10
use spec\Scriptotek\Alma\SpecHelper;
11
12 View Code Duplication
class RepresentationsSpec extends ObjectBehavior
0 ignored issues
show
Duplication introduced by
This class 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...
13
{
14
    public function let(AlmaClient $client, Bib $bib)
15
    {
16
        $bib->mms_id = 'abc';
17
        $this->beConstructedWith($client, $bib);
18
    }
19
20
    function it_is_initializable()
21
    {
22
        $this->shouldHaveType(Representations::class);
23
    }
24
25
    protected function expectRequest($client)
26
    {
27
        $client->getJSON('/bibs/abc/representations')
28
            ->shouldBeCalled()
29
            ->willReturn(SpecHelper::getDummyData('representations_response.json'));
30
    }
31
32
    public function it_is_countable(AlmaClient $client)
33
    {
34
        $this->expectRequest($client);
35
36
        $this->shouldHaveCount(2);
37
    }
38
}
39