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

KnockoutOptionsetField   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 37
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\OptionsetField;
7
8
/**
9
 * KnockoutOptionsetField
10
 *
11
 * Creates a {@link OptionsetField} with an additional data-bind attribute that
12
 * links to a Knockout obervable
13
 */
14
class KnockoutOptionsetField extends OptionsetField
15
{
16
    use \AntonyThorpe\Knockout\Common;
17
18
    /**
19
     * bindingType
20
     *
21
     * @var string a data-bind attribute key
22
     * @example   <ul data-bind="checked: accessories, etc. "
23
     */
24
    protected $bindingType = 'checked';
25
26
    /**
27
     * casting of variables for security purposes
28
     *
29
     * @see http://docs.silverstripe.org/en/3.1/developer_guides/security/secure_coding/
30
     */
31
    protected $casting = array(
32
        "Observable" => "Varchar",
33
        "BindingType" => "Varchar",
34
        "OtherBindings" => "Varchar",
35
        "HasFocus" => "Boolean"
36
    );
37
38
    /**
39
     * Constructor
40
     *
41
     * @param string $name The field name
42
     * @param string $title The field title
43
     * @param array $source An map of the dropdown items
44
     * @param string $value The current value
45
     * @param Form $form The parent 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...
46
     */
47
    public function __construct($name, $title = null, $source = array(), $value = '', $form = null)
48
    {
49
        parent::__construct($name, $title, $source, $value, $form);
0 ignored issues
show
Unused Code introduced by
The call to SilverStripe\Forms\SelectField::__construct() has too many arguments starting with $form. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
        parent::/** @scrutinizer ignore-call */ 
50
                __construct($name, $title, $source, $value, $form);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
50
        $this->addExtraClass('optionset');
51
    }
52
}
53