Requests::urlBase()   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 0
dl 4
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Scriptotek\Alma\Users;
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 Request resources.
12
 */
13 View Code Duplication
class Requests extends LazyResourceList implements \Countable, \Iterator, \ArrayAccess
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
    protected $_urlBase;
19
20
    /**
21
     * Requests constructor.
22
     *
23
     * @param Client $client
24
     * @param string $url
25
     */
26
    public function __construct(Client $client, $url)
27
    {
28
        parent::__construct($client, 'user_request');
29
        $this->_urlBase = $url;
30
    }
31
32
    /**
33
     * Convert a data element to a resource object.
34
     *
35
     * @param $data
36
     *
37
     * @return Request
38
     */
39
    protected function convertToResource($data)
40
    {
41
        return Request::make($this->client, User::make($this->client, $data->user_primary_id), $data->request_id)
42
            ->init($data);
43
    }
44
45
    /**
46
     * Generate the base URL for this resource.
47
     *
48
     * @return string
49
     */
50
    protected function urlBase()
51
    {
52
        return $this->_urlBase;
53
    }
54
}
55