Code Duplication    Length = 33-33 lines in 2 locations

src/Criteria/WithAttributeInValuesCriterion.php 1 location

@@ 5-37 (lines=33) @@
2
3
namespace Napp\Core\Dbal\Criteria;
4
5
class WithAttributeInValuesCriterion implements CriterionInterface
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $attribute;
11
12
    /**
13
     * @var array
14
     */
15
    protected $values;
16
17
    /**
18
     * @param string $attribute
19
     * @param array $values
20
     */
21
    public function __construct($attribute, $values)
22
    {
23
        $this->attribute = $attribute;
24
        $this->values = $values;
25
    }
26
27
    /**
28
     * @param \Illuminate\Database\Eloquent\Builder $query
29
     * @return \Illuminate\Database\Eloquent\Builder
30
     */
31
    public function apply($query)
32
    {
33
        $query->getQuery()->whereIn($query->getModel()->getTable() . '.' . $this->attribute, $this->values);
34
35
        return $query;
36
    }
37
}
38

src/Criteria/WithAttributeNotInValuesCriterion.php 1 location

@@ 5-37 (lines=33) @@
2
3
namespace Napp\Core\Dbal\Criteria;
4
5
class WithAttributeNotInValuesCriterion implements CriterionInterface
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $attribute;
11
12
    /**
13
     * @var array
14
     */
15
    protected $values;
16
17
    /**
18
     * @param string $attribute
19
     * @param array $values
20
     */
21
    public function __construct($attribute, $values)
22
    {
23
        $this->attribute = $attribute;
24
        $this->values = $values;
25
    }
26
27
    /**
28
     * @param \Illuminate\Database\Eloquent\Builder $query
29
     * @return \Illuminate\Database\Eloquent\Builder
30
     */
31
    public function apply($query)
32
    {
33
        $query->getQuery()->whereNotIn($query->getModel()->getTable() . '.' . $this->attribute, $this->values);
34
35
        return $query;
36
    }
37
}
38