Passed
Push — main ( e2b5f1...353913 )
by Stefan
02:09
created

AbstractFormData::setBtnValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
namespace SKien\Formgenerator;
3
4
/**
5
 * Abstract class representing data for the FormGenerator.
6
 *
7
 * @package Formgenerator
8
 * @author Stefanius <[email protected]>
9
 * @copyright MIT License - see the LICENSE file for details
10
 */
11
abstract class AbstractFormData implements FormDataInterface
12
{
13
    /** @var array containing all data that can be edited by the form     */
14
    protected array $aValues;
15
    /** @var array containing select list to be displayed by the form     */
16
    protected array $aSelectOptions;
17
    
18
    /**
19
     * (non-PHPdoc)
20
     * @see \SKien\Formgenerator\FormDataInterface::getValue()
21
     */
22
    public function getValue(string $strName)
23
    {
24
        return $this->aValues[$strName] ?? '';
25
    }
26
27
    /**
28
     * (non-PHPdoc)
29
     * @see \SKien\Formgenerator\FormDataInterface::getSelectOptions()
30
     */
31
    public function getSelectOptions(string $strName) : array
32
    {
33
        return $this->aSelectOptions[$strName] ?? [];
34
    }
35
    
36
    /**
37
     * Set value for specified element.
38
     * @param string $strName
39
     * @param mixed $value
40
     */
41
    public function setValue(string $strName, $value) : void
42
    {
43
        $this->aValues[$strName] = $value;
44
    }
45
    
46
    /**
47
     * Set selections for specified elemnt
48
     * @param string $strName
49
     * @param array $aOptions
50
     */
51
    public function setSelectOptions(string $strName, array $aOptions) : void
52
    {
53
        $this->aSelectOptions[$strName] = $aOptions;
54
    }
55
}
56
57