Completed
Push — master ( 6b5beb...afd247 )
by Freek
01:16
created

SearchableAttribute::createExact()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Spatie\Searchable;
4
5
class SearchableAttribute
6
{
7
    /** @var string */
8
    protected $attribute;
9
10
    /** @var bool */
11
    protected $partial;
12
13
    public function __construct(string $attribute, bool $partial = true)
14
    {
15
        $this->attribute = $attribute;
16
17
        $this->partial = $partial;
18
    }
19
20
    public static function create(string $attribute, bool $partial = true): self
21
    {
22
        return new self($attribute, $partial);
23
    }
24
25
    public static function createExact(string $attribute): self
26
    {
27
        return static::create($attribute, false);
28
    }
29
30
    public static function createMany(array $attributes): array
31
    {
32
        return collect($attributes)
33
            ->map(function ($attribute) {
34
                return new self($attribute);
35
            })
36
            ->toArray();
37
    }
38
39
    public function getAttribute(): string
40
    {
41
        return $this->attribute;
42
    }
43
44
    public function isPartial(): bool
45
    {
46
        return $this->partial;
47
    }
48
}
49