Completed
Push — master ( d9d1e2...b73c31 )
by Ruben
01:14
created

LinkType   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 3
cbo 1
dl 0
loc 36
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
getLinks() 0 1 ?
A parameters() 0 8 2
A prefix() 0 6 1
A serializer() 0 6 1
1
<?php
2
3
namespace Spatie\ResourceLinks\LinkTypes;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Support\Arr;
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
    abstract public function getLinks(Model $model = null): array;
20
21
    public function parameters(...$parameters)
22
    {
23
        foreach ($parameters as $parameter) {
24
            $this->parameters = array_merge($this->parameters, Arr::wrap($parameter));
25
        }
26
27
        return $this;
28
    }
29
30
    public function prefix(?string $prefix)
31
    {
32
        $this->prefix = $prefix;
33
34
        return $this;
35
    }
36
37
    public function serializer(?string $serializer)
38
    {
39
        $this->serializer = $serializer;
40
41
        return $this;
42
    }
43
}
44