Portfolio   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

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

4 Methods

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