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

Libraries::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Scriptotek\Alma\Conf;
4
5
use Scriptotek\Alma\ArrayAccessResource;
6
use Scriptotek\Alma\CountableGhostModelList;
7
use Scriptotek\Alma\IterableResource;
8
9
class Libraries extends CountableGhostModelList implements \ArrayAccess, \Countable, \Iterator
10
{
11
    use ArrayAccessResource;
12
    use IterableResource;
13
14
    /**
15
     * Get resource.
16
     *
17
     * @param string $code
18
     * @return Library
19
     */
20
    public function get($code)
21
    {
22
        return Library::make($this->client, $code);
23
    }
24
25
    protected function setData(\stdClass $data)
26
    {
27
        $this->resources = array_map(
28
            function (\stdClass $library) {
29
                return Library::make($this->client, $library->code)
30
                    ->init($library);
31
            },
32
            $data->library
33
        );
34
    }
35
36
    /**
37
     * Check if we have the full representation of our data object.
38
     *
39
     * @param \stdClass $data
40
     * @return boolean
41
     */
42
    protected function isInitialized($data)
43
    {
44
        return isset($data->library);
45
    }
46
47
    /**
48
     * Generate the base URL for this resource.
49
     *
50
     * @return string
51
     */
52
    protected function urlBase()
53
    {
54
        return "/conf/libraries";
55
    }
56
}
57