With   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A apply() 0 6 2
A __construct() 0 3 1
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
Bug Best Practice introduced by
The expression $this->with of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

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.

Loading history...
33
34
        return $queryBuilder;
35
    }
36
37
}
38