Fee::getItem()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 6
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Scriptotek\Alma\Users;
4
5
use Scriptotek\Alma\Bibs\Item;
6
use Scriptotek\Alma\Client;
7
use Scriptotek\Alma\Model\LazyResource;
8
9
/**
10
 * A single Fee resource.
11
 */
12 View Code Duplication
class Fee 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...
13
{
14
    /* @var User */
15
    protected $user;
16
17
    /* @var string */
18
    protected $id;
19
20
    public function __construct(Client $client, User $user, $id)
21
    {
22
        parent::__construct($client);
23
        $this->user = $user;
24
        $this->id = $id;
25
    }
26
27
    /**
28
     * Generate the base URL for this resource.
29
     *
30
     * @return string
31
     */
32
    protected function urlBase()
33
    {
34
        return sprintf('/users/%s/fees/%s', rawurlencode($this->user->id), $this->id);
35
    }
36
37
    /**
38
     * Check if we have the full representation of our data object.
39
     *
40
     * @param \stdClass $data
41
     *
42
     * @return bool
43
     */
44
    protected function isInitialized($data)
45
    {
46
        return isset($data->link);
47
    }
48
49
    /**
50
     * Get the related Item, if any.
51
     *
52
     * @return Item|null
53
     */
54
    public function getItem()
55
    {
56
        if (isset($this->barcode)) {
57
            return $this->client->items->fromBarcode($this->barcode);
58
        }
59
    }
60
}
61