EditableAncestryField   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 10
lcom 0
cbo 1
dl 0
loc 61
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getFieldConfiguration() 0 5 1
A getFormField() 0 4 1
A getValidation() 0 5 1
B getValueFromData() 0 19 6
A Icon() 0 4 1
1
<?php
2
/**
3
 *
4
 * @package userforms
5
 * @subpackage relatives
6
 */
7
8
class EditableAncestryField 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 = 'Ancestry field';
11
12
    public static $plural_name = 'Ancestry 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 AncestryField($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
        $returnValue = "";
47
        $value = (isset($data[$this->Name])) ? $data[$this->Name] : false;
48
        if ($value) {
49
            if (is_array($value)) {
50
                foreach ($value as $key => $dataEntered) {
51
                    $key = str_replace("Field", "", $key);
52
                    $key = str_replace("m", "mother-", $key);
53
                    $key = str_replace("f", "father-", $key);
54
                    if (!$dataEntered) {
55
                        $dataEntered = "---";
56
                    }
57
                    $returnValue .= "<br />$key: $dataEntered ";
58
                }
59
            }
60
        }
61
        return $returnValue;
62
    }
63
64
    public function Icon()
65
    {
66
        return 'userforms_relatives/images/icons/' . strtolower($this->class) . '.png';
67
    }
68
}
69