SimpleEloquent   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 6
c 2
b 1
f 0
dl 0
loc 31
ccs 6
cts 6
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A newEloquentBuilder() 0 3 1
A allSimple() 0 10 2
1
<?php
2
3
namespace Volosyuk\SimpleEloquent;
4
5
use Illuminate\Support\Collection;
6
use stdClass;
7
use Volosyuk\SimpleEloquent\Relations\HasRelationships;
8
9
/**
10
 * Trait SimpleEloquent
11
 *
12
 * @package Volosyuk\SimpleEloquent
13
 * @authour Volosyuk Andrey <[email protected]>
14
 */
15
trait SimpleEloquent
16
{
17
    use HasRelationships;
18
19
    /**
20
     * Create a new Eloquent query builder for the model.
21
     *
22
     * @param  Builder  $query
23
     * @return Builder|static
24
     */
25 33
    public function newEloquentBuilder($query)
26
    {
27 33
        return new Builder($query);
0 ignored issues
show
Bug introduced by
$query of type Volosyuk\SimpleEloquent\Builder is incompatible with the type Illuminate\Database\Query\Builder expected by parameter $query of Volosyuk\SimpleEloquent\Builder::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

27
        return new Builder(/** @scrutinizer ignore-type */ $query);
Loading history...
28
    }
29
30
    /**
31
     * Get all of the models from the database.
32
     *
33
     * @param  array|mixed  $columns
34
     * @return Collection|stdClass[]|array
35
     */
36 1
    public static function allSimple($columns = ['*'])
37
    {
38 1
        $columns = is_array($columns) ? $columns : func_get_args();
39
40
        /**
41
         * @var Builder $query
42
         */
43 1
        $query = (new static)->newQuery();
0 ignored issues
show
Bug introduced by
It seems like newQuery() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        $query = (new static)->/** @scrutinizer ignore-call */ newQuery();
Loading history...
44
45 1
        return $query->simple()->get($columns);
46
    }
47
}
48