Holdings::urlBase()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
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\Client;
6
use Scriptotek\Alma\Model\IterableCollection;
7
use Scriptotek\Alma\Model\LazyResourceList;
8
use Scriptotek\Alma\Model\ReadOnlyArrayAccess;
9
10
/**
11
 * Iterable collection of Holding resources belonging to some Bib resource.
12
 */
13 View Code Duplication
class Holdings extends LazyResourceList 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...
14
{
15
    use ReadOnlyArrayAccess;
16
    use IterableCollection;
17
18
    /**
19
     * The Bib this Holdings list belongs to.
20
     *
21
     * @var Bib
22
     */
23
    public $bib;
24
25
    /**
26
     * Holdings constructor.
27
     *
28
     * @param Client $client
29
     * @param Bib    $bib
30
     */
31
    public function __construct(Client $client, Bib $bib)
32
    {
33
        parent::__construct($client, 'holding');
34
        $this->bib = $bib;
35
    }
36
37
    /**
38
     * Get a single holding record by id.
39
     *
40
     * @param string $holding_id
41
     *
42
     * @return Holding
43
     */
44
    public function get($holding_id)
45
    {
46
        return Holding::make($this->client, $this->bib, $holding_id);
47
    }
48
49
    /**
50
     * Convert a data element to a resource object.
51
     *
52
     * @param $data
53
     *
54
     * @return Holding
55
     */
56
    protected function convertToResource($data)
57
    {
58
        return Holding::make($this->client, $this->bib, $data->holding_id)
59
            ->init($data);
60
    }
61
62
    /**
63
     * Generate the base URL for this resource.
64
     *
65
     * @return string
66
     */
67
    protected function urlBase()
68
    {
69
        return "/bibs/{$this->bib->mms_id}/holdings";
70
    }
71
}
72