Passed
Push — master ( 9234be...3143c1 )
by Arthur
20:30
created

Repository::model()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 2
nop 0
dl 0
loc 5
ccs 0
cts 5
cp 0
crap 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace Foundation\Abstracts\Repositories;
5
6
use Larapie\Repository\Eloquent\BaseRepository;
7
use Larapie\Repository\Exceptions\RepositoryException;
8
9
class Repository extends BaseRepository
10
{
11
    protected $eloquent;
12
13
    public function model()
14
    {
15
        if (!isset($this->eloquent) || !is_string($this->eloquent))
16
            throw new RepositoryException("Model not defined on " . static::class);
17
        return $this->eloquent;
18
    }
19
20
    public function resolve($id){
21
        if ($id instanceof $this->model) {
22
            return $id;
23
        }
24
25
        return $this->model::find($id);
26
    }
27
}