Test Failed
Push — master ( c6b6d3...528954 )
by Dan Michael O.
03:21
created

Holdings::getResources()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Scriptotek\Alma\Bibs;
4
5
use Scriptotek\Alma\ArrayAccessResource;
6
use Scriptotek\Alma\Client;
7
use Scriptotek\Alma\CountableGhostModelList;
8
use Scriptotek\Alma\IterableResource;
9
10 View Code Duplication
class Holdings extends CountableGhostModelList implements \Countable, \Iterator, \ArrayAccess
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...
11
{
12
    use ArrayAccessResource;
13
    use IterableResource;
14
15
    /* @var Bib */
16
    public $bib;
17
18
    public function __construct(Client $client, Bib $bib)
19
    {
20
        parent::__construct($client);
21
        $this->bib = $bib;
22
    }
23
24
    /**
25
     * Get resource.
26
     *
27
     * @param string $holding_id
28
     * @return Holding
29
     */
30
    public function get($holding_id)
31
    {
32
        return Holding::make($this->client, $this->bib, $holding_id);
33
    }
34
35
    public function setData(\stdClass $data)
36
    {
37
        $this->resources = array_map(
38
            function (\stdClass $holding) {
39
                return Holding::make($this->client, $this->bib, $holding->holding_id)
40
                    ->init($holding);
41
            },
42
            $data->holding
43
        );
44
    }
45
46
    /**
47
     * Check if we have the full representation of our data object.
48
     *
49
     * @param \stdClass $data
50
     * @return boolean
51
     */
52
    protected function isInitialized($data)
53
    {
54
        return $data->total_record_count;
55
    }
56
57
    /**
58
     * Generate the base URL for this resource.
59
     *
60
     * @return string
61
     */
62
    protected function urlBase()
63
    {
64
        return "/bibs/{$this->bib->mms_id}/holdings";
65
    }
66
}
67