Completed
Pull Request — master (#9)
by Roman
03:37
created

GetReflectionFromRequestStep   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 9 2
A requiresBefore() 0 3 1
1
<?php
2
3
namespace Kami\ApiCoreBundle\RequestProcessor\Step\Common;
4
5
use Kami\ApiCoreBundle\RequestProcessor\ProcessorResponse;
6
use Kami\ApiCoreBundle\RequestProcessor\Step\AbstractStep;
7
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
8
9
10
class GetReflectionFromRequestStep extends AbstractStep
11
{
12
13
    /**
14
     * @throws NotFoundHttpException
15
     * @return ProcessorResponse|\Kami\ApiCoreBundle\RequestProcessor\ResponseInterface
16
     */
17
    public function execute()
18
    {
19
        try {
20
            return $this->createResponse(
21
                ['reflection' => new \ReflectionClass($this->request->attributes->get('_entity'))]
22
            );
23
24
        } catch (\ReflectionException $e) {
25
            throw new NotFoundHttpException();
26
        }
27
    }
28
29
    /**
30
     * @return array
31
     */
32
    public function requiresBefore()
33
    {
34
        return [];
35
    }
36
}