Completed
Push — master ( 2c64ed...ead60c )
by Ruben
07:32
created

EndpointType   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 1

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
getEndpoints() 0 1 ?
A parameters() 0 6 1
A prefix() 0 6 1
A formatter() 0 6 1
A hasParameters() 0 4 1
1
<?php
2
3
namespace Spatie\LaravelResourceEndpoints\EndpointTypes;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Support\Arr;
7
8
abstract class EndpointType
9
{
10
    /** @var array */
11
    protected $parameters = [];
12
13
    /** @var string|null */
14
    protected $prefix;
15
16
    /** @var string|null */
17
    protected $formatter;
18
19
    abstract public function getEndpoints(Model $model = null): array;
20
21
    public function parameters($parameters)
22
    {
23
        $this->parameters = Arr::wrap($parameters);
24
25
        return $this;
26
    }
27
28
    public function prefix(?string $prefix)
29
    {
30
        $this->prefix = $prefix;
31
32
        return $this;
33
    }
34
35
    public function formatter(?string $formatter)
36
    {
37
        $this->formatter = $formatter;
38
39
        return $this;
40
    }
41
42
    public function hasParameters(): bool
43
    {
44
        return count($this->parameters) > 0;
45
    }
46
}
47