Model::newCollection()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Ianrizky\Illuminate\Database\Eloquent;
4
5
use Ianrizky\Illuminate\Database\Query\Builder as QueryBuilder;
6
use Illuminate\Database\Eloquent\Model as BaseModel;
7
8
/**
9
 * @property int $id
10
 * @method static \Ianrizky\Illuminate\Database\Eloquent\Builder on(string|null $connection) Begin querying the model on a given connection.
11
 * @method static \Ianrizky\Illuminate\Database\Query\Builder onWriteConnection() Begin querying the model on the write connection.
12
 * @method static \Ianrizky\Illuminate\Database\Eloquent\Builder with(array|string $relations) Begin querying a model with eager loading.
13
 * @method static \Ianrizky\Illuminate\Database\Eloquent\Builder query() Begin querying the model.
14
 * @method \Ianrizky\Illuminate\Database\Eloquent\Builder newQuery() Get a new query builder for the model's table.
15
 * @method \Ianrizky\Illuminate\Database\Eloquent\Builder|static newModelQuery() Get a new query builder that doesn't have any global scopes or eager loading.
16
 * @method \Ianrizky\Illuminate\Database\Eloquent\Builder newQueryWithoutRelationships() Get a new query builder with no relationships loaded.
17
 * @method \Ianrizky\Illuminate\Database\Eloquent\Builder registerGlobalScopes(\Ianrizky\Illuminate\Database\Eloquent\Builder $builder) Register the global scopes for this builder instance.
18
 * @method \Ianrizky\Illuminate\Database\Eloquent\Builder|static newQueryWithoutScopes() Get a new query builder that doesn't have any global scopes.
19
 * @method \Ianrizky\Illuminate\Database\Eloquent\Builder newQueryWithoutScope(\Illuminate\Database\Eloquent\Scope|string $scope) Get a new query instance without a given scope.
20
 * @method \Ianrizky\Illuminate\Database\Eloquent\Builder newQueryForRestoration(array|int $ids) Get a new query to restore one or more models by their queueable IDs.
21
 */
22
abstract class Model extends BaseModel
23
{
24
    use Concerns\HandleModel,
0 ignored issues
show
Bug introduced by
The trait Ianrizky\Illuminate\Data...nt\Concerns\HandleModel requires the property $morphName which is not provided by Ianrizky\Illuminate\Database\Eloquent\Model.
Loading history...
25
        Concerns\HasAttributes,
26
        Concerns\HasTimestamps,
27
        Concerns\Tappable,
28
        Docblock\EloquentBuilder;
29
30
    /**
31
     * {@inheritDoc}
32
     *
33
     * @param  \Ianrizky\Illuminate\Database\Query\Builder  $query
34
     * @return \Ianrizky\Illuminate\Database\Eloquent\Builder|static
35
     */
36
    public function newEloquentBuilder($query): Builder
37
    {
38
        return new Builder($query);
39
    }
40
41
    /**
42
     * {@inheritDoc}
43
     *
44
     * @return \Ianrizky\Illuminate\Database\Query\Builder
45
     */
46
    protected function newBaseQueryBuilder(): QueryBuilder
47
    {
48
        return parent::newBaseQueryBuilder();
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::newBaseQueryBuilder() returns the type Illuminate\Database\Query\Builder which includes types incompatible with the type-hinted return Ianrizky\Illuminate\Database\Query\Builder.
Loading history...
49
    }
50
51
    /**
52
     * {@inheritDoc}
53
     *
54
     * @return \Ianrizky\Illuminate\Database\Eloquent\Collection
55
     */
56
    public function newCollection(array $models = []): Collection
57
    {
58
        return new Collection($models);
59
    }
60
}
61