ExampleServiceI::update()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Modules\Example\Services;
4
5
use Modules\Core\Supports\Response;
6
use Modules\Example\Repositories\ExampleRepository;
7
8
class ExampleServiceI implements ExampleService
9
{
10
    /**
11
     * @var \Modules\Example\Repositories\ExampleRepository
12
     */
13
    private $exampleRepository;
14
15
    public function __construct(ExampleRepository $dataRepository)
16
    {
17
        $this->exampleRepository = $dataRepository;
18
    }
19
20
    public function index(): Response
21
    {
22
        return Response::handleOk($this->exampleRepository->all());
23
    }
24
25
    public function store(array $attributes): Response
26
    {
27
        return Response::handleCreated($this->exampleRepository->create($attributes));
28
    }
29
30
    public function show(int $id): Response
31
    {
32
        return Response::handleOk($this->exampleRepository->find($id));
33
    }
34
35
    public function update(int $id, array $attributes): Response
36
    {
37
        return Response::handleResetContent($this->exampleRepository->update($attributes, $id));
38
    }
39
40
    public function destroy(int $id): Response
41
    {
42
        return Response::handleNoContent($this->exampleRepository->delete($id));
43
    }
44
}
45