Completed
Push — master ( eaf16e...6f8e07 )
by Mohamed
11:01
created

Moo_EditableFieldNumeric   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 40%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 26
ccs 4
cts 10
cp 0.4
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getFieldValidationOptions() 0 10 3
A initFormField() 0 7 1
1
<?php
2
3
/**
4
 * Moo_EditableFieldNumeric is an object representing numeric field created by CMS admin.
5
 *
6
 * @package editablefield
7
 *
8
 * @author  Mohamed Alsharaf <[email protected]>
9
 */
10
class Moo_EditableFieldNumeric extends Moo_EditableField
11
{
12
    private static $singular_name   = 'Numeric Field';
13
    private static $plural_name     = 'Numeric Fields';
14
    protected $customSettingsFields = [
15
        'MinValue', 'MaxValue',
16
    ];
17 1
    protected function initFormField()
18
    {
19 1
        $field = new NumericField($this->Name, $this->Title);
20 1
        $field->addExtraClass('number');
21
22 1
        return $field;
23
    }
24
25
    public function getFieldValidationOptions()
26
    {
27
        $min = ($this->getSetting('MinValue')) ? $this->getSetting('MinValue') : '';
28
        $max = ($this->getSetting('MaxValue')) ? $this->getSetting('MaxValue') : '';
29
30
        return [
31
            new NumericField($this->getSettingName('MinValue'), _t('Moo_EditableField.MINVALUE', 'Min Value'), $min),
32
            new NumericField($this->getSettingName('MaxValue'), _t('Moo_EditableField.MAXVALUE', 'Max Value'), $max),
33
        ];
34
    }
35
}
36