Completed
Push — master ( 99f799...7b8dce )
by Andrey
04:09
created

ContextBuilderFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 0 10 2
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/form-comparator
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\FormComparator\Context;
7
8
use Webmozart\Assert\Assert;
9
use Zend\ServiceManager\AbstractPluginManager;
10
use Zend\ServiceManager\FactoryInterface;
11
use Zend\ServiceManager\ServiceLocatorInterface;
12
use Zend\Form\FormElementManager;
13
14
/**
15
 * Class ContextBuilderFactory
16
 *
17
 * @package Nnx\FormComparator\Context
18
 */
19
class ContextBuilderFactory implements FactoryInterface
20
{
21
    /**
22
     * @inheritdoc
23
     *
24
     * @param ServiceLocatorInterface $serviceLocator
25
     *
26
     * @return ContextBuilder
27
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
28
     */
29
    public function createService(ServiceLocatorInterface $serviceLocator)
30
    {
31
        $appServiceLocator = $serviceLocator instanceof AbstractPluginManager ? $serviceLocator->getServiceLocator() : $serviceLocator;
32
33
        /** @var FormElementManager $formElementManager */
34
        $formElementManager = $appServiceLocator->get('FormElementManager');
35
        Assert::isInstanceOf($formElementManager, FormElementManager::class);
36
37
        return new ContextBuilder($formElementManager);
38
    }
39
40
}
41