Passed
Push — master ( 7bc374...cf39f3 )
by Arthur
05:05
created

MachineService::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 04.10.18
6
 * Time: 16:17.
7
 */
8
9
namespace Modules\Machine\Services;
10
11
use Modules\Machine\Contracts\MachineServiceContract;
12
use Modules\Machine\Entities\Machine;
13
use Modules\Machine\Events\MachineRegisteredEvent;
14
15
class MachineService implements MachineServiceContract
16
{
17
    public function find($id): ?Machine
18
    {
19
        return Machine::find($id);
0 ignored issues
show
Bug Best Practice introduced by
The expression return Modules\Machine\Entities\Machine::find($id) could return the type Illuminate\Database\Eloquent\Model which includes types incompatible with the type-hinted return null|Modules\Machine\Entities\Machine. Consider adding an additional type-check to rule them out.
Loading history...
20
    }
21
22
    public function update($id, $data): Machine
23
    {
24
        $user = $this->find($id);
25
        $user->update($data);
26
27
        return $user;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $user could return the type null which is incompatible with the type-hinted return Modules\Machine\Entities\Machine. Consider adding an additional type-check to rule them out.
Loading history...
28
    }
29
30
    public function create($data): Machine
31
    {
32
        $machine = Machine::create($data);
33
        event(new MachineRegisteredEvent($machine));
34
35
        return $machine;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $machine could return the type Illuminate\Database\Eloquent\Model which includes types incompatible with the type-hinted return Modules\Machine\Entities\Machine. Consider adding an additional type-check to rule them out.
Loading history...
36
    }
37
38
    public function delete($id): bool
39
    {
40
        return Machine::destroy($id);
0 ignored issues
show
Bug Best Practice introduced by
The expression return Modules\Machine\E...s\Machine::destroy($id) returns the type integer which is incompatible with the type-hinted return boolean.
Loading history...
41
    }
42
}
43