EagerLoad   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A apply() 0 3 1
1
<?php
2
3
namespace Orkhanahmadov\EloquentRepository\Repository\Eloquent\Criteria;
4
5
use Illuminate\Support\Arr;
6
use Illuminate\Database\Eloquent\Builder;
7
use Orkhanahmadov\EloquentRepository\Repository\Criteria\Criterion;
8
9
class EagerLoad implements Criterion
10
{
11
    /**
12
     * @var array
13
     */
14
    protected $relations;
15
16
    /**
17
     * EagerLoad constructor.
18
     *
19
     * @param mixed ...$relations
20
     */
21
    public function __construct(...$relations)
22
    {
23
        $this->relations = Arr::flatten($relations);
24
    }
25
26
    /**
27
     * @param Builder|mixed $model
28
     *
29
     * @return Builder|mixed
30
     */
31
    public function apply($model)
32
    {
33
        return $model->with($this->relations);
34
    }
35
}
36