SimpleEloquent::allSimple()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 2
eloc 3
c 2
b 1
f 0
nc 2
nop 1
dl 0
loc 10
ccs 4
cts 4
cp 1
crap 2
rs 10
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