Test Failed
Push — master ( c6b6d3...528954 )
by Dan Michael O.
03:21
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 setData() 0 4 1
A urlBase() 0 4 1
A getRecord() 0 4 1
A getItems() 0 4 1
1
<?php
2
3
namespace Scriptotek\Alma\Bibs;
4
5
use Scriptotek\Alma\Client;
6
use Scriptotek\Alma\GhostModel;
7
use Scriptotek\Marc\Record as MarcRecord;
8
9
class Holding extends GhostModel
10
{
11
    /* @var string */
12
    public $holding_id;
13
14
    /* @var Bib */
15
    public $bib;
16
17
    /* @var Items */
18
    public $items;
19
20
    /* @var MarcRecord */
21
    protected $_marc;
22
23
    public function __construct(Client $client, Bib $bib, $holding_id)
24
    {
25
        parent::__construct($client);
26
        $this->bib = $bib;
27
        $this->holding_id = $holding_id;
28
        $this->items = Items::make($this->client, $bib, $this);
29
    }
30
31
    /**
32
     * Check if we have the full representation of our data object.
33
     *
34
     * @param \stdClass $data
35
     * @return boolean
36
     */
37
    protected function isInitialized($data)
38
    {
39
        return isset($data->anies);
40
    }
41
42
    /**
43
     * Store data onto object.
44
     *
45
     * @param \stdClass $data
46
     */
47
    protected function setData(\stdClass $data)
48
    {
49
        $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...
50
    }
51
52
    /**
53
     * Generate the base URL for this resource.
54
     *
55
     * @return string
56
     */
57
    protected function urlBase()
58
    {
59
        return "/bibs/{$this->bib->mms_id}/holdings/{$this->holding_id}";
60
    }
61
62
    /**
63
     * Get the MARC record.
64
     */
65
    public function getRecord()
66
    {
67
        return $this->init()->_marc;
68
    }
69
70
    /**
71
     * Get the items for this holding.
72
     */
73
    public function getItems()
74
    {
75
        return $this->items;
76
    }
77
}
78