Repository::show()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
namespace App\Repositories;
3
4
use Illuminate\Database\Eloquent\Model;
5
6
class Repository implements RepositoryInterface
7
{
8
    protected $model;
9
10
    public function __construct(Model $model)
11
    {
12
        $this->model = $model;
13
    }
14
15
    public function all()
16
    {
17
        return $this->model->all();
18
    }
19
20
    public function create(array $data)
21
    {
22
        return $this->model->create($data);
23
    }
24
25
    public function update(array $data, int $id)
26
    {
27
        $record = $this->find($id);
0 ignored issues
show
Bug introduced by
The method find() does not exist on App\Repositories\Repository. ( Ignorable by Annotation )

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

27
        /** @scrutinizer ignore-call */ 
28
        $record = $this->find($id);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
28
        return $record->update($data);
29
    }
30
31
    public function delete(int $id)
32
    {
33
        return $this->model->destroy($id);
34
    }
35
36
    public function show(int $id)
37
    {
38
        return $this->model->findOrFail($id);
39
    }
40
41
    public function getModel()
42
    {
43
        return $this->model;
44
    }
45
46
    public function setModel($model) 
47
    {
48
        $this->model = $model;
49
        return $this;
50
    }
51
52
    public function with($relations)
53
    {
54
        return $this->model->with($relations);
55
    }
56
}