belamov /
postgres-range
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Belamov\PostgresRange\Macros; |
||||
| 4 | |||||
| 5 | use Belamov\PostgresRange\Ranges\Range; |
||||
| 6 | use Illuminate\Database\Query\Builder; |
||||
| 7 | |||||
| 8 | class QueryBuilderMacros |
||||
| 9 | { |
||||
| 10 | public array $macrosParams = [ |
||||
| 11 | ['RangeContains', '@>'], |
||||
| 12 | ['RangeDoesNotExtendToTheLeftOf', '&>'], |
||||
| 13 | ['RangeDoesNotExtendToTheRightOf', '&<'], |
||||
| 14 | ['RangeAdjacentTo', '-|-'], |
||||
| 15 | ['RangeIsContainedBy', '<@'], |
||||
| 16 | ['RangeOverlaps', '&&'], |
||||
| 17 | ['RangeStrictlyLeftOf', '<<'], |
||||
| 18 | ['RangeStrictlyRightOf', '>>'], |
||||
| 19 | |||||
| 20 | ]; |
||||
| 21 | |||||
| 22 | public function register(): void |
||||
| 23 | { |
||||
| 24 | foreach ($this->macrosParams as [$operatorName, $operator]) { |
||||
| 25 | Builder::macro( |
||||
| 26 | "where{$operatorName}", |
||||
| 27 | fn ($left, $right) => $this->whereRaw( |
||||
|
0 ignored issues
–
show
|
|||||
| 28 | sprintf('%s %s %s', |
||||
| 29 | $left instanceof Range ? $left->forSql() : $left, |
||||
| 30 | $operator, |
||||
| 31 | $right instanceof Range ? $right->forSql() : $right |
||||
| 32 | ) |
||||
| 33 | ) |
||||
| 34 | ); |
||||
| 35 | |||||
| 36 | Builder::macro( |
||||
| 37 | "orWhere{$operatorName}", |
||||
| 38 | fn ($left, $right) => $this->orWhereRaw( |
||||
|
0 ignored issues
–
show
The method
orWhereRaw() does not exist on Belamov\PostgresRange\Macros\QueryBuilderMacros.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 39 | sprintf('%s %s %s', |
||||
| 40 | $left instanceof Range ? $left->forSql() : $left, |
||||
| 41 | $operator, |
||||
| 42 | $right instanceof Range ? $right->forSql() : $right |
||||
| 43 | ) |
||||
| 44 | ) |
||||
| 45 | ); |
||||
| 46 | } |
||||
| 47 | } |
||||
| 48 | } |
||||
| 49 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.