Test Failed
Push — master ( 5f574e...cd391d )
by Pavel
01:40
created

ShowAction::show()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.864

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 1
nop 1
dl 0
loc 9
ccs 2
cts 5
cp 0.4
crap 2.864
rs 9.6666
c 0
b 0
f 0
1
<?php namespace Pz\Doctrine\Rest\Action;
2
3
use Pz\Doctrine\Rest\Request\ShowRequestInterface;
4
use Pz\Doctrine\Rest\RestRepository;
5
use Pz\Doctrine\Rest\RestResponseInterface;
6
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpKe...n\NotFoundHttpException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
trait ShowAction
9
{
10
    /**
11
     * Doctrine repository from where get data.
12
     *
13
     * @return RestRepository
14
     */
15
    abstract protected function repository();
16
17
    /**
18
     * @return RestResponseInterface
19
     */
20
    abstract protected function response();
21
22
    /**
23
     * @param ShowRequestInterface $request
24
     *
25
     * @return array
26
     */
27 1
    public function show(ShowRequestInterface $request)
28
    {
29 1
        if (null === ($entity = $this->repository()->find($request->getId()))) {
30
            throw new NotFoundHttpException();
31
        }
32
33
        $request->authorize($entity);
34
35
        return $this->response()->show($request, $entity);
36
    }
37
}
38