okaybueno /
laravel-repositories
| 1 | <?php |
||
| 2 | |||
| 3 | namespace OkayBueno\Repositories\Criteria\Eloquent; |
||
| 4 | |||
| 5 | use OkayBueno\Repositories\Criteria\CriteriaInterface; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Class With |
||
| 9 | * @package OkayBueno\Repositories\Criteria\Eloquent |
||
| 10 | */ |
||
| 11 | class With implements CriteriaInterface |
||
| 12 | { |
||
| 13 | |||
| 14 | protected $with = NULL; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * With constructor. |
||
| 18 | * @param array $with |
||
| 19 | */ |
||
| 20 | public function __construct( array $with = [] ) |
||
| 21 | { |
||
| 22 | $this->with = $with; |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param mixed $queryBuilder |
||
| 27 | * @return mixed |
||
| 28 | */ |
||
| 29 | public function apply( $queryBuilder ) |
||
| 30 | { |
||
| 31 | // Do something with the query builder and return it. |
||
| 32 | if ( $this->with ) $queryBuilder->with( $this->with ); |
||
|
0 ignored issues
–
show
|
|||
| 33 | |||
| 34 | return $queryBuilder; |
||
| 35 | } |
||
| 36 | |||
| 37 | } |
||
| 38 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.