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

KnockoutTextField::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 5
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace AntonyThorpe\Knockout;
4
5
require_once('Common.php');
6
use SilverStripe\Forms\TextField;
7
8
/**
9
 * KnockoutTextField
10
 *
11
 * Creates a {@link TextField} with an additional data-bind attribute that links to a Knockout obervable
12
 */
13
class KnockoutTextField extends TextField
14
{
15
    use \AntonyThorpe\Knockout\Common;
16
17
    /**
18
     * bindingType
19
     *
20
     * KnockoutTextField needs either 'value' or 'textInput' as a key for the 'data-bind' HTML attribute
21
     *
22
     * @var string data-bind attribute key
23
     * @example  data-bind="input: name, valueUpdate: 'input'" - the binding type is: input.
24
     */
25
    protected $bindingType = "textInput";
26
27
    /**
28
     * casting of variables for security purposes
29
     *
30
     * @see http://docs.silverstripe.org/en/3.1/developer_guides/security/secure_coding/
31
     */
32
    protected $casting = array(
33
        "Observable" => "Varchar",
34
        "BindingType" => "Varchar",
35
        "OtherBindings" => "Varchar",
36
        "HasFocus" => "Boolean"
37
    );
38
39
    /**
40
     * Constructor
41
     *
42
     * @param string $name
43
     * @param null|string $title
44
     * @param string $value
45
     * @param null|int $maxLength
46
     * @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...
47
     */
48
    public function __construct($name, $title = null, $value = '', $maxLength = null, $form = null)
49
    {
50
        parent::__construct($name, $title, $value, $maxLength, $form);
51
        $this->addExtraClass('text');
52
    }
53
}
54