updateCMSFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 10
cts 10
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 1
crap 1
1
<?php
2
3
class DynamicContentBlockDataExtension extends DataExtension
4
{
5
    /**
6
     * @var array
7
     */
8
    private static $db = array(
9
        'SubTitle' => 'Varchar(255)',
10
    );
11
12
    /**
13
     * @var array
14
     */
15
    private static $has_one = array(
16
        'Image' => 'Image',
17
        'BlockLink' => 'Link',
18
    );
19
20
    /**
21
     * @param FieldList $fields
22
     */
23 1
    public function updateCMSFields(FieldList $fields)
24
    {
25 1
        $image = ImageUploadField::create('Image')
26 1
            ->setFolderName('Uploads/Blocks/Content');
27 1
        $fields->insertBefore($image, 'Content');
0 ignored issues
show
Documentation introduced by
'Content' is of type string, but the function expects a object<FormField>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
28
29 1
        $fields->addFieldToTab(
30 1
            'Root.Main',
31 1
            LinkField::create('BlockLinkID', 'Link'),
32
            'Image'
33 1
        );
34
35 1
        $fields->insertAfter(TextField::create('SubTitle'), 'Title');
0 ignored issues
show
Documentation introduced by
'Title' is of type string, but the function expects a object<FormField>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
36 1
    }
37
38
}