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

KnockoutEmailField   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
1
<?php
2
3
namespace AntonyThorpe\Knockout;
4
5
require_once('Common.php');
6
use SilverStripe\Forms\EmailField;
7
8
/**
9
 * KnockoutEmailField
10
 *
11
 * Creates a {@link EmailField} with an additional data-bind attribute that links to a Knockout obervable
12
 */
13
class KnockoutEmailField extends EmailField
14
{
15
16
    use \AntonyThorpe\Knockout\Common;
17
18
    /**
19
     * bindingType
20
     *
21
     * KnockoutEmailField needs either 'value' or 'textInput' as a key for the 'data-bind' HTML attribute.
22
     * Default to textInput for live updates
23
     *
24
     * @var string data-bind attribute key
25
     * @example  data-bind="textInput: email" - the binding type is: textInput.
26
     */
27
    protected $bindingType = "textInput";
28
29
    /**
30
     * casting of variables for security purposes
31
     *
32
     * @see http://docs.silverstripe.org/en/3.1/developer_guides/security/secure_coding/
33
     */
34
    protected $casting = array(
35
        "Observable" => "Varchar",
36
        "BindingType" => "Varchar",
37
        "OtherBindings" => "Varchar",
38
        "HasFocus" => "Boolean"
39
    );
40
41
    /**
42
     * Constructor
43
     *
44
     * @param string $name
45
     * @param null|string $title
46
     * @param string $value
47
     * @param null|int $maxLength
48
     * @param null|Form $form
0 ignored issues
show
Bug introduced by
The type AntonyThorpe\Knockout\Form was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
49
     */
50
    public function __construct($name, $title = null, $value = '', $maxLength = null, $form = null)
51
    {
52
        parent::__construct($name, $title, $value, $maxLength, $form);
53
        $this->setTemplate('AntonyThorpe\Knockout\KnockoutTextField');
54
    }
55
}
56