Representation::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 3
dl 7
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Scriptotek\Alma\Bibs;
4
5
use Scriptotek\Alma\Client;
6
use Scriptotek\Alma\Model\LazyResource;
7
8
/**
9
 * A single Representation resource.
10
 */
11 View Code Duplication
class Representation 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...
12
{
13
    /* @var string */
14
    public $representation_id;
15
16
    /* @var Bib */
17
    public $bib;
18
19
    /* @var Files */
20
    public $files;
21
22
    public function __construct(Client $client, Bib $bib, $representation_id)
23
    {
24
        parent::__construct($client);
25
        $this->bib = $bib;
26
        $this->representation_id = $representation_id;
27
        $this->files = Files::make($this->client, $bib, $this);
28
    }
29
30
    /**
31
     * Generate the base URL for this resource.
32
     *
33
     * @return string
34
     */
35
    protected function urlBase()
36
    {
37
        return "/bibs/{$this->bib->mms_id}/representations/{$this->representation_id}";
38
    }
39
40
    /**
41
     * Get the files for this representation.
42
     */
43
    public function getFiles()
44
    {
45
        return $this->files;
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->delivery_url);
58
    }
59
}
60