Skip to content

Commit

Permalink
Fixes docblock and use strpos.
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Dec 8, 2019
1 parent d045573 commit a6c2cd8
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ return $orderable->apply($query)->get();
```

```sql
select * FROM `users` ORDER BY `name` DESC;
select * from `users` order by `name` desc;
```

> The code will validate the column name before trying to apply `orderBy()` to the query, this would prevent SQL injection especially when column is given by the user.
Expand Down
3 changes: 0 additions & 3 deletions src/Searchable.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public function apply($query)
* Build wildcard query filter for field using where or orWhere.
*
* @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
* @param \Laravie\QueryFilter\Value\Field $column
*
* @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder
*/
Expand All @@ -84,7 +83,6 @@ protected function queryOnColumn($query, Value\Field $column, string $likeOperat
* Build wildcard query filter for column using where or orWhere.
*
* @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
* @param \Laravie\QueryFilter\Value\Field $column
*
* @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder
*/
Expand Down Expand Up @@ -113,7 +111,6 @@ protected function queryOnColumnUsing(
* Build wildcard query filter for JSON column using where or orWhere.
*
* @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
* @param \Laravie\QueryFilter\Value\Field $column
*
* @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected function matchTaggedConditions($query): void
}

foreach ($this->rules as $keyword => $callback) {
if (Str::contains($keyword, ':*') || Str::contains($keyword, ':[]')) {
if (\strpos($keyword, ':*') !== false || \strpos($keyword, ':[]') !== false) {
[$tag, $type] = \explode(':', $keyword, 2);

$results = Arr::where($tagged, static function ($value) use ($tag) {
Expand Down
4 changes: 2 additions & 2 deletions src/Value/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public function validate(): bool
*/
public function isRelationSelector(): bool
{
return Str::contains($this->name, '.');
return \strpos($this->name, '.') !== false;
}

/**
* Is JSON path selector.
*/
public function isJsonPathSelector(): bool
{
return Str::contains($this->name, '->');
return \strpos($this->name, '->') !== false;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Value/Keywords.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(string $basic, array $tagged)
/**
* Parse rules from keyword.
*
* @return array
* @return static
*/
public static function parse(string $keyword, array $rules)
{
Expand Down

0 comments on commit a6c2cd8

Please sign in to comment.