CountryDropdownField   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
eloc 8
dl 0
loc 23
rs 10
c 2
b 0
f 2
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
1
<?php
2
3
namespace LeKoala\GeoTools\Fields;
4
5
use ArrayAccess;
6
use LeKoala\GeoTools\CountriesList;
7
use SilverStripe\Forms\DropdownField;
8
9
class CountryDropdownField extends DropdownField
10
{
11
    /**
12
     * @var bool
13
     */
14
    protected $hasEmptyDefault = true;
15
16
    /**
17
     * @param string $name
18
     * @param string$title
19
     * @param array<string,string>|ArrayAccess<string,string> $source
20
     * @param mixed $value
21
     */
22
    public function __construct($name = 'CountryCode', $title = null, $source = [], $value = null)
23
    {
24
        if ($title === null) {
25
            $title = _t('CountryDropdownField.TITLE', 'Country');
26
        }
27
        if (empty($source)) {
28
            $source = CountriesList::get();
29
        }
30
        $this->setEmptyString(_t('CountryDropdownField.PLEASESELECTACOUNTRY', 'Please select a country'));
31
        parent::__construct($name, $title, $source, $value);
32
    }
33
}
34