-
Notifications
You must be signed in to change notification settings - Fork 1
/
WithScoutSupport.php
34 lines (27 loc) · 963 Bytes
/
WithScoutSupport.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php declare(strict_types = 1);
namespace LastDragon_ru\LaraASP\GraphQL\Builder\Traits;
use Composer\InstalledVersions;
use Composer\Semver\VersionParser;
use Laravel\Scout\Builder as ScoutBuilder;
use LastDragon_ru\LaraASP\GraphQL\Builder\Directives\OperatorDirective;
use Override;
use function is_a;
/**
* @phpstan-require-extends OperatorDirective
*/
trait WithScoutSupport {
#[Override]
protected function isBuilderSupported(string $builder): bool {
return parent::isBuilderSupported($builder)
|| (is_a($builder, ScoutBuilder::class, true) && $this->isScoutSupported());
}
protected function isScoutSupported(): bool {
$version = $this->getScoutVersion();
$supported = $version === null
|| InstalledVersions::satisfies(new VersionParser(), 'laravel/scout', $version);
return $supported;
}
protected function getScoutVersion(): ?string {
return null;
}
}