Completed
Push — master ( bbe9c9...dc72bb )
by Ruben
01:46
created

LinkType::query()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Spatie\ResourceLinks\LinkTypes;
4
5
use Illuminate\Support\Arr;
6
use Illuminate\Database\Eloquent\Model;
7
8
abstract class LinkType
9
{
10
    /** @var array */
11
    protected $parameters = [];
12
13
    /** @var string|null */
14
    protected $prefix;
15
16
    /** @var string|null */
17
    protected $serializer;
18
19
    /** @var string|null */
20
    protected $query;
21
22
    abstract public function getLinks(Model $model = null): array;
23
24
    public function parameters(...$parameters)
25
    {
26
        foreach ($parameters as $parameter) {
27
            $this->parameters = array_merge($this->parameters, Arr::wrap($parameter));
28
        }
29
30
        return $this;
31
    }
32
33
    public function prefix(?string $prefix)
34
    {
35
        $this->prefix = $prefix;
36
37
        return $this;
38
    }
39
40
    public function serializer(?string $serializer)
41
    {
42
        $this->serializer = $serializer;
43
44
        return $this;
45
    }
46
47
    public function query(?string $query)
48
    {
49
        $this->query = $query;
50
51
        return $this;
52
    }
53
}
54