Code Duplication    Length = 41-59 lines in 5 locations

src/Users/Fees.php 1 location

@@ 13-68 (lines=56) @@
10
/**
11
 * Iterable collection of Fee resources.
12
 */
13
class Fees extends LazyResourceList implements \Countable, \Iterator, \ArrayAccess
14
{
15
    use ReadOnlyArrayAccess;
16
    use IterableCollection;
17
18
    /**
19
     * The User object this Fees list belongs to.
20
     *
21
     * @var User
22
     */
23
    public $user;
24
25
    /**
26
     * Fees constructor.
27
     *
28
     * @param Client $client
29
     * @param User   $user
30
     */
31
    public function __construct(Client $client, User $user)
32
    {
33
        parent::__construct($client, 'fee');
34
        $this->user = $user;
35
    }
36
37
    /**
38
     * Get a single Fee by id.
39
     *
40
     * @param string $id
41
     *
42
     * @return Fee
43
     */
44
    public function get($id)
45
    {
46
        return Fee::make($this->client, $this->user, $id);
47
    }
48
49
    /**
50
     * Convert a retrieved resource object to a model object.
51
     *
52
     * @param $data
53
     *
54
     * @return Fee
55
     */
56
    public function convertToResource($data)
57
    {
58
        return $this->get($data->id)->init($data);
59
    }
60
61
    /**
62
     * Generate the base URL for this resource.
63
     *
64
     * @return string
65
     */
66
    protected function urlBase()
67
    {
68
        return "/users/{$this->user->id}/fees";
69
    }
70
}
71

src/Users/Requests.php 1 location

@@ 13-53 (lines=41) @@
10
/**
11
 * Iterable collection of Request resources.
12
 */
13
class Requests extends LazyResourceList implements \Countable, \Iterator, \ArrayAccess
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

src/Bibs/ElectronicCollections.php 1 location

@@ 11-69 (lines=59) @@
8
use Scriptotek\Alma\Model\LazyResourceList;
9
use Scriptotek\Alma\Model\ReadOnlyArrayAccess;
10
11
class ElectronicCollections extends LazyResourceList implements \Countable, \Iterator, \ArrayAccess
12
{
13
    use ReadOnlyArrayAccess;
14
    use IterableCollection;
15
16
    /**
17
     * The Bib this ElectronicCollections list belongs to.
18
     *
19
     * @var Bib
20
     */
21
    public $bib;
22
23
    /**
24
     * ElectronicCollections constructor.
25
     *
26
     * @param Client $client
27
     * @param Bib    $bib
28
     */
29
    public function __construct(Client $client, Bib $bib)
30
    {
31
        parent::__construct($client, 'electronic_collection');
32
        $this->bib = $bib;
33
    }
34
35
    /**
36
     * Get a single electronic collection record by id.
37
     *
38
     * @param string $id
39
     *
40
     * @return Representation
41
     */
42
    public function get($id)
43
    {
44
        return Collection::make($this->client, $id);
45
    }
46
47
    /**
48
     * Convert a data element to a resource object.
49
     *
50
     * @param $data
51
     *
52
     * @return Representation
53
     */
54
    protected function convertToResource($data)
55
    {
56
        return Collection::make($this->client, $data->id)
57
            ->init($data);
58
    }
59
60
    /**
61
     * Generate the base URL for this resource.
62
     *
63
     * @return string
64
     */
65
    protected function urlBase()
66
    {
67
        return "/bibs/{$this->bib->mms_id}/e-collections";
68
    }
69
}
70

src/Bibs/Portfolios.php 1 location

@@ 12-70 (lines=59) @@
9
use Scriptotek\Alma\Model\LazyResourceList;
10
use Scriptotek\Alma\Model\ReadOnlyArrayAccess;
11
12
class Portfolios extends LazyResourceList implements \Countable, \Iterator, \ArrayAccess
13
{
14
    use ReadOnlyArrayAccess;
15
    use IterableCollection;
16
17
    /**
18
     * The Bib this Portfolios list belongs to.
19
     *
20
     * @var Bib
21
     */
22
    public $bib;
23
24
    /**
25
     * Portfolios constructor.
26
     *
27
     * @param Client $client
28
     * @param Bib    $bib
29
     */
30
    public function __construct(Client $client, Bib $bib)
31
    {
32
        parent::__construct($client, 'portfolio');
33
        $this->bib = $bib;
34
    }
35
36
    /**
37
     * Get a single portfolio record by id.
38
     *
39
     * @param string $id
40
     *
41
     * @return Portfolio
42
     */
43
    public function get($id)
44
    {
45
        return Portfolio::make($this->client, $this->bib, $id);
46
    }
47
48
    /**
49
     * Convert a data element to a resource object.
50
     *
51
     * @param $data
52
     *
53
     * @return Portfolio
54
     */
55
    protected function convertToResource($data)
56
    {
57
        return Portfolio::make($this->client, $this->bib, $data->id)
58
            ->init($data);
59
    }
60
61
    /**
62
     * Generate the base URL for this resource.
63
     *
64
     * @return string
65
     */
66
    protected function urlBase()
67
    {
68
        return "/bibs/{$this->bib->mms_id}/portfolios";
69
    }
70
}
71

src/Bibs/Representations.php 1 location

@@ 10-68 (lines=59) @@
7
use Scriptotek\Alma\Model\LazyResourceList;
8
use Scriptotek\Alma\Model\ReadOnlyArrayAccess;
9
10
class Representations extends LazyResourceList implements \Countable, \Iterator, \ArrayAccess
11
{
12
    use ReadOnlyArrayAccess;
13
    use IterableCollection;
14
15
    /**
16
     * The Bib this Representations list belongs to.
17
     *
18
     * @var Bib
19
     */
20
    public $bib;
21
22
    /**
23
     * Representations constructor.
24
     *
25
     * @param Client $client
26
     * @param Bib    $bib
27
     */
28
    public function __construct(Client $client, Bib $bib)
29
    {
30
        parent::__construct($client, 'representation');
31
        $this->bib = $bib;
32
    }
33
34
    /**
35
     * Get a single representation record by id.
36
     *
37
     * @param string $id
38
     *
39
     * @return Representation
40
     */
41
    public function get($id)
42
    {
43
        return Representation::make($this->client, $this->bib, $id);
44
    }
45
46
    /**
47
     * Convert a data element to a resource object.
48
     *
49
     * @param $data
50
     *
51
     * @return Representation
52
     */
53
    protected function convertToResource($data)
54
    {
55
        return Representation::make($this->client, $this->bib, $data->id)
56
            ->init($data);
57
    }
58
59
    /**
60
     * Generate the base URL for this resource.
61
     *
62
     * @return string
63
     */
64
    protected function urlBase()
65
    {
66
        return "/bibs/{$this->bib->mms_id}/representations";
67
    }
68
}
69