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

Libraries   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 4 1
A convertToResource() 0 5 1
A urlBase() 0 4 1
1
<?php
2
3
namespace Scriptotek\Alma\Conf;
4
5
use Scriptotek\Alma\Client;
6
use Scriptotek\Alma\Model\ReadOnlyArrayAccess;
7
use Scriptotek\Alma\Model\LazyResourceList;
8
use Scriptotek\Alma\Model\IterableCollection;
9
10
/**
11
 * Iterable collection of Library resources.
12
 */
13
class Libraries extends LazyResourceList implements \ArrayAccess, \Countable, \Iterator
14
{
15
    use ReadOnlyArrayAccess;
16
    use IterableCollection;
17
18
    /**
19
     * Locations constructor.
20
     *
21
     * @param Client $client
22
     */
23
    public function __construct(Client $client)
24
    {
25
        parent::__construct($client, 'library');
26
    }
27
28
    /**
29
     * Get a single library by its library code.
30
     *
31
     * @param string $code
32
     * @return Library
33
     */
34
    public function get($code)
35
    {
36
        return Library::make($this->client, $code);
37
    }
38
39
    /**
40
     * Convert a data element to a resource object.
41
     *
42
     * @param $data
43
     * @return Library
44
     */
45
    protected function convertToResource($data)
46
    {
47
        return Library::make($this->client, $data->code)
48
            ->init($data);
49
    }
50
51
    /**
52
     * Generate the base URL for this resource.
53
     *
54
     * @return string
55
     */
56
    protected function urlBase()
57
    {
58
        return "/conf/libraries";
59
    }
60
}
61