Passed
Push — master ( bf3235...abf80a )
by Antony
02:59
created

KnockoutFormAction::getDisabledClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace AntonyThorpe\Knockout;
4
5
require_once('Common.php');
6
7
/**
8
 * KnockoutFormAction
9
 *
10
 * Wrap HTML in an Knockout if statement to disable the submit key when invalid (as per Knockout Validation)
11
 */
12
class KnockoutFormAction extends \SilverStripe\Forms\FormAction
13
{
14
15
    use \AntonyThorpe\Knockout\Common;
16
17
    /**
18
     * $disabledClass
19
     *
20
     * @var string a disabledClass
21
     */
22
    protected $disabledClass = "FormAction_Disabled";
23
24
    /**
25
     * casting of variables for security purposes
26
     *
27
     * @see http://docs.silverstripe.org/en/3.1/developer_guides/security/secure_coding/
28
     */
29
    protected $casting = array(
30
        "DisabledClass" => "Varchar",
31
        "Observable" => "Varchar",
32
        "BindingType" => "Varchar",
33
        "OtherBindings" => "Varchar",
34
        "HasFocus" => "Boolean"
35
    );
36
37
    /**
38
     * setDisabledClass
39
     *
40
     * @param string $input The CSS class appied to the element upon a falsy observable result
41
     * @return $this
42
     */
43
    public function setDisabledClass($input)
44
    {
45
        $this->disabledClass = (string)$input;
46
        return $this;
47
    }
48
49
    /**
50
     * getDisabledClass
51
     *
52
     * @return boolean
53
     */
54
    public function getDisabledClass()
55
    {
56
        return $this->disabledClass;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->disabledClass returns the type string which is incompatible with the documented return type boolean.
Loading history...
57
    }
58
}
59