Completed
Pull Request — master (#24)
by
unknown
05:45 queued 03:36
created

CodeTables::getCodeTables()   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 0
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\Client;
6
use Scriptotek\Alma\Model\ReadOnlyArrayAccess;
7
8
/**
9
 * A non-iterable collection of CodeTable resources
10
 */
11
class CodeTables implements \ArrayAccess
12
{
13
    use ReadOnlyArrayAccess;
14
15
    protected $client;
16
17
    /**
18
     * CodeTables constructor.
19
     *
20
     * @param Client $client
21
     */
22
    public function __construct(Client $client)
23
    {
24
        $this->client = $client;
25
    }
26
27
    /**
28
     * Get a CodeTable by identifier
29
     *
30
     * @param $code The identifier of a CodeTable
31
     *
32
     * @return CodeTable
33
     */
34
    public function get($code)
35
    {
36
        return CodeTable::make($this->client, $code);
37
    }
38
39
    /**
40
    * Return a object containing a list of code tables.
41
    *
42
    * @return CodeTable ojbect list.
43
    */
44
    public function getCodeTables()
45
    {
46
        return json_decode($this->client->get($this->urlBase()));
47
    }
48
    
49
    /**
50
    * Generate the base URL for this resource.
51
    *
52
    * @return string
53
    */
54
    protected function urlBase()
55
    {
56
        return '/conf/code-tables';
57
    }
58
    
59
}
60