Library::isInitialized()   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\LazyResource;
7
8
/**
9
 * A single Library resource.
10
 */
11 View Code Duplication
class Library extends LazyResource
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...
12
{
13
    /** @var string */
14
    public $code;
15
16
    /** @var Locations */
17
    public $locations;
18
19
    /**
20
     * Library constructor.
21
     *
22
     * @param Client $client
23
     * @param string $code
24
     */
25
    public function __construct(Client $client, $code)
26
    {
27
        parent::__construct($client);
28
        $this->code = $code;
29
        $this->locations = Locations::make($this->client, $this);
30
    }
31
32
    /**
33
     * Check if we have the full representation of our data object.
34
     * For libraries, it seems like we get the same data in the list
35
     * response as in the single-item response, so we just check some
36
     * random element.
37
     *
38
     * @param \stdClass $data
39
     *
40
     * @return bool
41
     */
42
    protected function isInitialized($data)
43
    {
44
        return isset($data->path);
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/{$this->code}";
55
    }
56
}
57