Passed
Branch master (e5ff15)
by Antony
01:18
created

KnockoutFormAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setDisabledClass() 0 4 1
A getDisabledClass() 0 3 1
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