SourceType::getParent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace RunOpenCode\Bundle\ExchangeRate\Form\Type;
4
5
use RunOpenCode\ExchangeRate\Configuration;
6
use RunOpenCode\ExchangeRate\Contract\RatesConfigurationRegistryInterface;
7
use Symfony\Component\Form\AbstractType;
8
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
9
use Symfony\Component\OptionsResolver\OptionsResolver;
10
11
/**
12
 * Class SourceType
13
 *
14
 * Source choices type.
15
 *
16
 * @package RunOpenCode\Bundle\ExchangeRate\Form\Type
17
 */
18 View Code Duplication
class SourceType extends AbstractType
0 ignored issues
show
Duplication introduced by
This class 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...
19
{
20
    /**
21
     * @var array
22
     */
23
    protected $defaults;
24
25 6
    public function __construct(RatesConfigurationRegistryInterface $registry, array $defaults = [])
26
    {
27 6
        $choices = [];
28
29
        /**
30
         * @var Configuration $configuration
31
         */
32 6
        foreach ($registry as $configuration) {
33 6
            $sourceName = $configuration->getSourceName();
34 6
            $choices[$sourceName] = $sourceName;
35
        }
36
37 6
        $this->defaults = array_merge(array(
38 6
            'choice_translation_domain' => 'runopencode_exchange_rate',
39 6
            'choices' => $choices
40 6
        ), $defaults);
41 6
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 5
    public function configureOptions(OptionsResolver $resolver)
47
    {
48 5
        $resolver->setDefaults($this->defaults);
49 5
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54 5
    public function getParent()
55
    {
56 5
        return ChoiceType::class;
57
    }
58
}
59