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

Portfolio::isInitialized()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 4
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Scriptotek\Alma\Bibs;
4
5
use Scriptotek\Alma\Bibs\Bib;
6
use Scriptotek\Alma\Client;
7
use Scriptotek\Alma\Electronic\Collection;
8
use Scriptotek\Alma\Model\LazyResource;
9
10
/**
11
 * A single Portfolio resource.
12
 */
13 View Code Duplication
class Portfolio 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...
14
{
15
    /* @var string */
16
    public $portfolio_id;
17
18
    /* @var Bib */
19
    public $bib;
20
21
    public function __construct(Client $client, Bib $bib, $portfolio_id)
22
    {
23
        parent::__construct($client);
24
        $this->bib = $bib;
25
        $this->portfolio_id = $portfolio_id;
26
    }
27
28
    /**
29
     * Generate the base URL for this resource.
30
     *
31
     * @return string
32
     */
33
    protected function urlBase()
34
    {
35
        return "/bibs/{$this->bib->mms_id}/portfolios/{$this->portfolio_id}";
36
    }
37
38
    /**
39
     * Check if we have the full representation of our data object.
40
     *
41
     * @param \stdClass $data
42
     *
43
     * @return bool
44
     */
45
    protected function isInitialized($data)
46
    {
47
        return isset($data->linking_details);
48
    }
49
50
    public function getElectronicCollection()
51
    {
52
        $this->init();
53
54
        return new Collection($this->client, $this->data->electronic_collection->id->value);
55
    }
56
}
57