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

File   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 52
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A urlBase() 4 4 1
A isInitialized() 4 4 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 Scriptotek\Alma\Bibs;
4
5
use Scriptotek\Alma\Client;
6
use Scriptotek\Alma\Model\LazyResource;
7
8 View Code Duplication
class File extends LazyResource
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...
9
{
10
    /** @var Bib */
11
    public $bib;
12
13
    /** @var Representation */
14
    public $representation;
15
16
    /** @var Requests */
17
    public $requests;
18
19
    /** @var string */
20
    public $file_id;
21
22
    /**
23
     * File constructor.
24
     *
25
     * @param Client  $client
26
     * @param Bib     $bib
27
     * @param Representation $representation
28
     * @param $file_id
29
     */
30
    public function __construct(Client $client, Bib $bib, Representation $representation, $file_id)
31
    {
32
        parent::__construct($client);
33
        $this->bib = $bib;
34
        $this->representation = $representation;
35
        $this->file_id = $file_id;
36
    }
37
38
    /**
39
     * Generate the base URL for this resource.
40
     *
41
     * @return string
42
     */
43
    protected function urlBase()
44
    {
45
        return "/bibs/{$this->bib->mms_id}/representations/{$this->representation->representation_id}/files/{$this->file_id}";
46
    }
47
48
    /**
49
     * Check if we have the full representation of our data object.
50
     *
51
     * @param \stdClass $data
52
     *
53
     * @return bool
54
     */
55
    protected function isInitialized($data)
56
    {
57
        return isset($data->path);
58
    }
59
}
60