sfWidgetFormI18nSelect2ChoiceCurrency   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 24
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B configure() 0 21 6
1
<?php
2
class sfWidgetFormI18nSelect2ChoiceCurrency extends sfWidgetFormSelect2Choice
3
{
4
    protected function configure($options = array(), $attributes = array())
5
    {
6
        parent::configure($options, $attributes);
7
8
        $this->addOption('culture', sfContext::getInstance()->getUser()->getCulture());
9
        $this->addOption('currencies');
10
        $this->addOption('add_empty', false);
11
12
        // populate choices with all currencies
13
        $culture = isset($options['culture']) ? $options['culture'] : 'en';
14
15
        $currencies = sfCultureInfo::getInstance($culture)->getCurrencies(isset($options['currencies']) ? $options['currencies'] : null);
16
17
        $addEmpty = isset($options['add_empty']) ? $options['add_empty'] : false;
18
        if (false !== $addEmpty)
19
        {
20
            $currencies = array_merge(array('' => true === $addEmpty ? '' : $addEmpty), $currencies);
21
        }
22
23
        $this->setOption('choices', $currencies);
24
    }
25
}