Repository::delete()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php namespace App\Repositories;
2
3
use Illuminate\Database\Eloquent\Model;
4
use Illuminate\Container\Container as App;
5
use App\Exceptions\RepositoryException;
6
7
abstract class Repository implements RepositoryInterface {
8
9
    protected $model;
10
11
    public function __construct(App $app)
12
    {
13
        $model = $app->make($this->getModelName());
14
15
        if( !$model instanceof Model ) {
16
            throw new RepositoryException('Model must be an instance of Illuminate\\Database\\Eloquent\\Model');
17
        }
18
19
        $this->model = $model;
20
    }
21
22
    public abstract function getModelName();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
23
24
    public function all()
25
    {
26
        throw new RepositoryException('Not yet implemented', RepositoryException::RESOURCE_DENIED);
27
    }
28
29
    public function get($id)
30
    {
31
        throw new RepositoryException('Not yet implemented', RepositoryException::RESOURCE_DENIED);
32
    }
33
34
    public function store(array $data)
35
    {
36
        throw new RepositoryException('Not yet implemented', RepositoryException::RESOURCE_DENIED);
37
    }
38
39
    public function update($id, array $data)
40
    {
41
        throw new RepositoryException('Not yet implemented', RepositoryException::RESOURCE_DENIED);
42
    }
43
44
    public function delete($id)
45
    {
46
        throw new RepositoryException('Not yet implemented', RepositoryException::RESOURCE_DENIED);
47
    }
48
49
    public function softDelete($id)
50
    {
51
        throw new RepositoryException('Not yet implemented', RepositoryException::RESOURCE_DENIED);
52
    }
53
54
    public function validate(array $data)
55
    {
56
        throw new RepositoryException('Not yet implemented', RepositoryException::RESOURCE_DENIED);
57
    }
58
59
    public function validateID($id)
60
    {
61
        if( (bool) preg_match('/^[0-9]{1,10}$/', $id) === false )
62
        {
63
            throw new RepositoryException('Parameter must be a positive integer', RepositoryException::INCORRECT_PARAMETER);
64
        }
65
    }
66
67
68
}