EditableOffSpringField::getValidation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/**
3
 *
4
 * @package userforms
5
 * @subpackage relatives
6
 */
7
8
class EditableOffSpringField extends EditableFormField
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
9
{
10
    public static $singular_name = 'Offspring field';
11
12
    public static $plural_name = 'Offspring fields';
13
14
    public function getFieldConfiguration()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
15
    {
16
        $fields = parent::getFieldConfiguration();
17
        return $fields;
18
    }
19
20
    public function getFormField()
21
    {
22
        return new OffSpringField($this->Name, $this->Title);
23
    }
24
25
    /**
26
     * Return the validation information related to this field. This is
27
     * interrupted as a JSON object for validate plugin and used in the
28
     * PHP.
29
     *
30
     * @see http://docs.jquery.com/Plugins/Validation/Methods
31
     * @return Array
32
     */
33
    public function getValidation()
34
    {
35
        $options = array();
36
        return $options;
37
    }
38
39
    /**
40
     * Return the Value of this Field
41
     *
42
     * @return String
43
     */
44
    public function getValueFromData($data)
45
    {
46
        $value = (isset($data[$this->Name])) ? $data[$this->Name] : false;
47
        if ($value) {
48
            $name = isset($value["name"]) ? $value["name"] : "-- not entered --";
49
            $dob = isset($value["dob"]) ? $value["dob"] : "-- not entered --";
50
            $sex = isset($value["sex"]) ? $value["sex"] : "-- not entered --";
51
            return "Name: $name | dob: $dob | sex: $sex";
52
        }
53
    }
54
55
    public function Icon()
56
    {
57
        return 'userforms_relatives/images/icons/' . strtolower($this->class) . '.png';
58
    }
59
}
60