Completed
Push — master ( 804c7f...1d2ba7 )
by Dan Michael O.
01:59
created

Files::urlBase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Scriptotek\Alma\Bibs;
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 File resources belonging to some Representation resource.
12
 */
13
class Files extends LazyResourceList implements \Countable, \Iterator, \ArrayAccess
14
{
15
    use ReadOnlyArrayAccess;
16
    use IterableCollection;
17
18
    /**
19
     * The Bib this Files list belongs to.
20
     *
21
     * @var Bib
22
     */
23
    public $bib;
24
25
    /**
26
     * The Representation this Files list belongs to.
27
     *
28
     * @var Representation
29
     */
30
    public $representation;
31
32
    /**
33
     * Files constructor.
34
     *
35
     * @param Client  $client
36
     * @param Bib     $bib
37
     * @param Representation $representation
38
     */
39
    public function __construct(Client $client, Bib $bib = null, Representation $representation = null)
40
    {
41
        parent::__construct($client, 'representation_file');
42
        $this->bib = $bib;
43
        $this->representation = $representation;
44
    }
45
46
    /**
47
     * Convert a data element to a resource object.
48
     *
49
     * @param $data
50
     *
51
     * @return File
52
     */
53
    protected function convertToResource($data)
54
    {
55
        return File::make($this->client, $this->bib, $this->representation, $data->pid)
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/{$this->representation->representation_id}/files";
67
    }
68
}
69