Completed
Push — master ( 9d90d4...cee823 )
by Dan Michael O.
03:06
created

Holding   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A isInitialized() 0 4 1
A urlBase() 0 4 1
A getRecord() 0 4 1
A getItems() 0 4 1
A onData() 0 4 1
1
<?php
2
3
namespace Scriptotek\Alma\Bibs;
4
5
use Scriptotek\Alma\Client;
6
use Scriptotek\Alma\Model\LazyResource;
7
use Scriptotek\Marc\Record as MarcRecord;
8
9
/**
10
 * A single Holding resource.
11
 */
12
class Holding extends LazyResource
13
{
14
    /* @var string */
15
    public $holding_id;
16
17
    /* @var Bib */
18
    public $bib;
19
20
    /* @var Items */
21
    public $items;
22
23
    /* @var MarcRecord */
24
    protected $_marc;
25
26
    public function __construct(Client $client, Bib $bib, $holding_id)
27
    {
28
        parent::__construct($client);
29
        $this->bib = $bib;
30
        $this->holding_id = $holding_id;
31
        $this->items = Items::make($this->client, $bib, $this);
32
    }
33
34
    /**
35
     * Check if we have the full representation of our data object.
36
     *
37
     * @param \stdClass $data
38
     * @return boolean
39
     */
40
    protected function isInitialized($data)
41
    {
42
        return isset($data->anies);
43
    }
44
45
    /**
46
     * Called when data is available to be processed.
47
     *
48
     * @param mixed $data
49
     */
50
    protected function onData($data)
51
    {
52
        $this->_marc = MarcRecord::fromString($data->anies[0]);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Scriptotek\Marc\Record:...String($data->anies[0]) of type object<Scriptotek\Marc\Collection> is incompatible with the declared type object<Scriptotek\Marc\Record> of property $_marc.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
53
    }
54
55
    /**
56
     * Generate the base URL for this resource.
57
     *
58
     * @return string
59
     */
60
    protected function urlBase()
61
    {
62
        return "/bibs/{$this->bib->mms_id}/holdings/{$this->holding_id}";
63
    }
64
65
    /**
66
     * Get the MARC record.
67
     */
68
    public function getRecord()
69
    {
70
        return $this->init()->_marc;
71
    }
72
73
    /**
74
     * Get the items for this holding.
75
     */
76
    public function getItems()
77
    {
78
        return $this->items;
79
    }
80
}
81