SearchAspect::getType()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Spatie\Searchable;
4
5
use Illuminate\Support\Collection;
6
use Illuminate\Support\Str;
7
8
abstract class SearchAspect
9
{
10
    abstract public function getResults(string $term): Collection;
11
12
    public function getType(): string
13
    {
14
        if (isset(static::$searchType)) {
15
            return static::$searchType;
16
        }
17
18
        $className = class_basename(static::class);
19
20
        $type = Str::before($className, 'SearchAspect');
21
22
        $type = Str::snake(Str::plural($type));
23
24
        return Str::plural($type);
25
    }
26
}
27