AbstractRepository   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 27
ccs 6
cts 8
cp 0.75
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A forceCreate() 0 7 1
A findWhere() 0 5 2
A findMany() 0 4 1
1
<?php
2
3
4
namespace Mvdstam\Oauth2ServerLaravel\Repositories;
5
6
7
use Czim\Repository\BaseRepository;
8
use Illuminate\Database\Eloquent\Model;
9
10
abstract class AbstractRepository extends BaseRepository
11
{
12
13
    /**
14
     * @param array $data
15
     * @return Model
16
     */
17 5
    public function forceCreate(array $data = [])
18
    {
19 5
        $model = $this->makeModel(false)->forceFill($data);
20 5
        $model->save();
21
22 5
        return $model;
23
    }
24
25 11
    public function findWhere($where, $columns = ['*'], $or = false)
26
    {
27
        // Ensure a collection is returned
28 11
        return parent::findWhere($where, $columns, $or) ?: collect();
0 ignored issues
show
Bug Compatibility introduced by
The expression parent::findWhere($where...mns, $or) ?: collect(); of type Illuminate\Database\Eloq...nate\Support\Collection adds the type Illuminate\Database\Eloquent\Builder[] to the return on line 28 which is incompatible with the return type declared by the interface Czim\Repository\Contract...oryInterface::findWhere of type Illuminate\Support\Collection|null.
Loading history...
29
    }
30
31
    public function findMany($ids, $columns = ['*'])
32
    {
33
        return $this->query()->findMany($ids, $columns);
34
    }
35
36
}
37