FormAnnotationBuilderFactory   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 4
dl 0
loc 45
ccs 12
cts 14
cp 0.8571
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createService() 0 4 1
A __invoke() 0 9 1
A getOptionsClass() 0 3 1
A getFormFactory() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineORMModule\Service;
6
7
use DoctrineModule\Service\AbstractFactory;
8
use DoctrineORMModule\Form\Annotation\AnnotationBuilder;
9
use Interop\Container\ContainerInterface;
10
use Laminas\Form\Factory;
11
use Laminas\ServiceManager\ServiceLocatorInterface;
12
13
/**
14
 * Service factory responsible for instantiating {@see \DoctrineORMModule\Form\Annotation\AnnotationBuilder}
15
 */
16
class FormAnnotationBuilderFactory extends AbstractFactory
17
{
18
    /**
19
     * {@inheritDoc}
20
     *
21
     * @return AnnotationBuilder
22
     */
23 1
    public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null)
24
    {
25 1
        $entityManager = $container->get('doctrine.entitymanager.' . $this->getName());
26
27 1
        $annotationBuilder = new AnnotationBuilder($entityManager);
28 1
        $annotationBuilder->setFormFactory($this->getFormFactory($container));
29
30 1
        return $annotationBuilder;
31
    }
32
33
    /**
34
     * {@inheritDoc}
35
     *
36
     * @return AnnotationBuilder
37
     */
38 1
    public function createService(ServiceLocatorInterface $container)
39
    {
40 1
        return $this($container, AnnotationBuilder::class);
41
    }
42
43
    public function getOptionsClass() : string
44
    {
45
    }
46
47
    /**
48
     * Retrieve the form factory
49
     */
50 1
    private function getFormFactory(ContainerInterface $services) : Factory
51
    {
52 1
        $elements = null;
53
54 1
        if ($services->has('FormElementManager')) {
55 1
            $elements = $services->get('FormElementManager');
56
        }
57
58 1
        return new Factory($elements);
59
    }
60
}
61