Completed
Push — master ( b13bbf...5b16af )
by Denis
04:07
created

Service::update()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Zendaemon\Services;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Zendaemon\Services\Contracts\ServiceInterface;
7
use Zendaemon\Services\Exceptions\ModelNotFoundException;
8
9
abstract class Service implements ServiceInterface
10
{
11
    /** @var Model */
12
    protected $model;
13
14
    /**
15
     * Service constructor.
16
     * @throws ModelNotFoundException
17
     */
18
    public function __construct()
19
    {
20
        $this->setModel();
21
22
        if (!$this->model || !class_exists($this->model)) {
23
            throw new ModelNotFoundException();
24
        }
25
    }
26
27
    /**
28
     * Set model class name.
29
     *
30
     * @return void
31
     */
32
    abstract protected function setModel(): void;
33
34
    public function getModel(): Model
35
    {
36
        return $this->model;
37
    }
38
}
39