Libraries::get()   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 1
dl 4
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\IterableCollection;
7
use Scriptotek\Alma\Model\LazyResourceList;
8
use Scriptotek\Alma\Model\ReadOnlyArrayAccess;
9
10
/**
11
 * Iterable collection of Library resources.
12
 */
13 View Code Duplication
class Libraries extends LazyResourceList implements \ArrayAccess, \Countable, \Iterator
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
     * 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
     *
33
     * @return Library
34
     */
35
    public function get($code)
36
    {
37
        return Library::make($this->client, $code);
38
    }
39
40
    /**
41
     * Convert a data element to a resource object.
42
     *
43
     * @param $data
44
     *
45
     * @return Library
46
     */
47
    protected function convertToResource($data)
48
    {
49
        return Library::make($this->client, $data->code)
50
            ->init($data);
51
    }
52
53
    /**
54
     * Generate the base URL for this resource.
55
     *
56
     * @return string
57
     */
58
    protected function urlBase()
59
    {
60
        return '/conf/libraries';
61
    }
62
}
63