Total Complexity | 5 |
Total Lines | 29 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | class TrimResponseStep extends AbstractStep |
||
11 | { |
||
12 | protected $accessManager; |
||
13 | |||
14 | public function __construct(AccessManager $accessManager) |
||
15 | { |
||
16 | $this->accessManager = $accessManager; |
||
17 | } |
||
18 | |||
19 | public function execute() |
||
20 | { |
||
21 | /** @var \ReflectionClass $reflection */ |
||
22 | $reflection = $this->getFromResponse('reflection'); |
||
23 | $persistedEntity = $this->getFromResponse('response_data'); |
||
24 | |||
25 | $data = []; |
||
26 | |||
27 | foreach ($reflection->getProperties() as $property) { |
||
28 | if ($this->accessManager->canAccessProperty($property)) { |
||
29 | $data[$property->getName()] = call_user_func([$persistedEntity, 'get'.ucfirst($property->getName())]); |
||
30 | } |
||
31 | } |
||
32 | |||
33 | return $this->createResponse(['response_data' => $data]); |
||
34 | } |
||
35 | |||
36 | public function requiresBefore() |
||
39 | } |
||
40 | } |