Completed
Pull Request — master (#90)
by Arnaud
16:42
created

ConfigurationFactory::createActionConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 9
loc 9
ccs 0
cts 8
cp 0
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 3
crap 2
1
<?php
2
3
namespace LAG\AdminBundle\Configuration\Factory;
4
5
use LAG\AdminBundle\Action\Configuration\ActionConfiguration;
6
use LAG\AdminBundle\Admin\AdminInterface;
7
use LAG\AdminBundle\Admin\Configuration\AdminConfiguration;
8
use LAG\AdminBundle\Application\Configuration\ApplicationConfiguration;
9
use Symfony\Component\OptionsResolver\OptionsResolver;
10
11
/**
12
 * Class ConfigurationFactory
13
 * @deprecated
14
 * @package LAG\AdminBundle\Configuration\Factory
15
 */
16
class ConfigurationFactory
17
{
18
    /**
19
     * @var ApplicationConfiguration
20
     */
21
    private $applicationConfiguration;
22
    
23
    /**
24
     * ConfigurationFactory constructor.
25
     *
26
     * @param array $configuration
27
     */
28 View Code Duplication
    public function __construct(array $configuration)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
    {
30
        $resolver = new OptionsResolver();
31
        $applicationConfiguration = new ApplicationConfiguration();
32
        $applicationConfiguration->configureOptions($resolver);
33
        $applicationConfiguration->setParameters($resolver->resolve($configuration));
34
    
35
        $this->applicationConfiguration = $applicationConfiguration;
36
    }
37
    
38
    /**
39
     * Create an action configuration object.
40
     *
41
     * @deprecated
42
     *
43
     * @param $actionName
44
     * @param AdminInterface $admin
45
     * @param array $configuration
46
     * @return ActionConfiguration
47
     */
48 View Code Duplication
    public function createActionConfiguration($actionName, AdminInterface $admin, array $configuration = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
    {
50
        $resolver = new OptionsResolver();
51
        $actionConfiguration = new ActionConfiguration($actionName, $admin->getName(), $admin->getConfiguration());
52
        $actionConfiguration->configureOptions($resolver);
53
        $actionConfiguration->setParameters($resolver->resolve($configuration));
54
55
        return $actionConfiguration;
56
    }
57
58
    /**
59
     * Create an admin configuration object.
60
     *
61
     * @deprecated
62
     *
63
     * @param array $configuration
64
     * @return AdminConfiguration
65
     */
66 View Code Duplication
    public function createAdminConfiguration(array $configuration = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
67
    {
68
        $resolver = new OptionsResolver();
69
        $adminConfiguration = new AdminConfiguration($this->applicationConfiguration);
70
        $adminConfiguration->configureOptions($resolver);
71
        $adminConfiguration->setParameters($resolver->resolve($configuration));
72
73
        return $adminConfiguration;
74
    }
75
76
    /**
77
     * @deprecated
78
     *
79
     * Return the Application configuration.
80
     *
81
     * @return ApplicationConfiguration
82
     */
83
    public function getApplicationConfiguration()
84
    {
85
        return $this->applicationConfiguration;
86
    }
87
}
88