Data   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 4 1
A hiddenTag() 0 8 2
A getKeys() 0 4 2
1
<?php
2
namespace Tuum\Form\Data;
3
4
class Data extends AbstractData
5
{
6
    // +----------------------------------------------------------------------+
7
    //  construction
8
    // +----------------------------------------------------------------------+
9
    /**
10
     * @param \Closure $closure
11
     */
12
    public function execute($closure)
13
    {
14
        return $closure($this->data);
15
    }
16
17
    /**
18
     * get value as hidden tag using $key as name.
19
     *
20
     * @param string $key
21
     * @return string
22
     */
23
    public function hiddenTag($key)
24
    {
25
        if ($this->offsetExists($key)) {
26
            $value = $this->get($key);
27
            return "<input type='hidden' name='{$key}' value='{$value}' />";
28
        }
29
        return '';
30
    }
31
32
    /**
33
     * get keys of current data (if it is an array).
34
     *
35
     * @return array
36
     */
37
    public function getKeys()
38
    {
39
        return is_array($this->data) ? array_keys($this->data) : [];
40
    }
41
42
}