Code Duplication    Length = 41-44 lines in 3 locations

src/RunOpenCode/Bundle/ExchangeRate/Form/Type/ForeignCurrencyCodeType.php 1 location

@@ 25-68 (lines=44) @@
22
 *
23
 * @package RunOpenCode\Bundle\ExchangeRate\Form\Type
24
 */
25
class ForeignCurrencyCodeType extends AbstractType
26
{
27
    /**
28
     * @var array
29
     */
30
    protected $defaults;
31
32
    public function __construct(RatesConfigurationRegistryInterface $registry, array $defaults = [])
33
    {
34
        $currencyCodes = [];
35
36
        /**
37
         * @var Configuration $configuration
38
         */
39
        foreach ($registry as $configuration) {
40
            $currencyCode = $configuration->getCurrencyCode();
41
            $currencyCodes[$currencyCode] = $currencyCode;
42
        }
43
44
        asort($currencyCodes);
45
46
        $this->defaults = array_merge(array(
47
            'choice_translation_domain' => false,
48
            'choices' => $currencyCodes
49
        ), $defaults);
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function configureOptions(OptionsResolver $resolver)
56
    {
57
        $resolver
58
            ->setDefaults($this->defaults);
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function getParent()
65
    {
66
        return ChoiceType::class;
67
    }
68
}
69

src/RunOpenCode/Bundle/ExchangeRate/Form/Type/RateTypeType.php 1 location

@@ 25-65 (lines=41) @@
22
 *
23
 * @package RunOpenCode\Bundle\ExchangeRate\Form\Type
24
 */
25
class RateTypeType extends AbstractType
26
{
27
    /**
28
     * @var array
29
     */
30
    protected $defaults;
31
32
    public function __construct(RatesConfigurationRegistryInterface $registry, array $defaults = [])
33
    {
34
        $choices = [];
35
36
        /**
37
         * @var Configuration $configuration
38
         */
39
        foreach ($registry as $configuration) {
40
            $rateType = $configuration->getRateType();
41
            $choices[$rateType] = $rateType;
42
        }
43
44
        $this->defaults = array_merge(array(
45
            'choice_translation_domain' => 'runopencode_exchange_rate',
46
            'choices' => $choices
47
        ), $defaults);
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function configureOptions(OptionsResolver $resolver)
54
    {
55
        $resolver->setDefaults($this->defaults);
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function getParent()
62
    {
63
        return ChoiceType::class;
64
    }
65
}
66

src/RunOpenCode/Bundle/ExchangeRate/Form/Type/SourceType.php 1 location

@@ 18-58 (lines=41) @@
15
 *
16
 * @package RunOpenCode\Bundle\ExchangeRate\Form\Type
17
 */
18
class SourceType extends AbstractType
19
{
20
    /**
21
     * @var array
22
     */
23
    protected $defaults;
24
25
    public function __construct(RatesConfigurationRegistryInterface $registry, array $defaults = [])
26
    {
27
        $choices = [];
28
29
        /**
30
         * @var Configuration $configuration
31
         */
32
        foreach ($registry as $configuration) {
33
            $sourceName = $configuration->getSourceName();
34
            $choices[$sourceName] = $sourceName;
35
        }
36
37
        $this->defaults = array_merge(array(
38
            'choice_translation_domain' => 'runopencode_exchange_rate',
39
            'choices' => $choices
40
        ), $defaults);
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function configureOptions(OptionsResolver $resolver)
47
    {
48
        $resolver->setDefaults($this->defaults);
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function getParent()
55
    {
56
        return ChoiceType::class;
57
    }
58
}
59