Passed
Push — develop ( b22678...97e476 )
by Daniel
08:45
created

FormMiddleware::getSubscribedServices()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Serializer\Middleware;
4
5
use Silverback\ApiComponentBundle\Entity\Component\Form\Form;
6
use Silverback\ApiComponentBundle\Factory\Form\FormViewFactory;
7
8
class FormMiddleware extends AbstractMiddleware
9
{
10
    public function process($form, array $context = array())
11
    {
12
        /** @var FormViewFactory $factory */
13
        $factory = $this->container->get(FormViewFactory::class);
14
        $form->setForm($factory->create($form));
15
    }
16
17
    public function supportsData($data): bool
18
    {
19
        return $data instanceof Form && !$data->getForm();
20
    }
21
22
    public static function getSubscribedServices(): array
23
    {
24
        return [
25
            '?' . FormViewFactory::class
26
        ];
27
    }
28
}
29