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

EndpointType::parameters()   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\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