Data::getKeys()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 0
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
}