Completed
Pull Request — master (#62)
by Jason
15:39
created

DynamicContentBlockDataExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 39
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateCMSFields() 0 17 1
1
<?php
2
3
namespace Dynamic\DynamicBlocks\ORM;
4
5
use SilverStripe\AssetAdmin\Forms\UploadField;
6
use SilverStripe\Assets\Image;
7
use SilverStripe\Forms\FieldList;
8
use SilverStripe\Forms\TextField;
9
use SilverStripe\ORM\DataExtension;
10
11
class DynamicContentBlockDataExtension extends DataExtension
12
{
13
    /**
14
     * @var array
15
     */
16
    private static $db = array(
17
        'SubTitle' => 'Varchar(255)',
18
    );
19
20
    /**
21
     * @var array
22
     */
23 1
    private static $has_one = array(
24
        'Image' => Image::class,
25 1
        //'BlockLink' => 'Link', // todo readd once Linkable is SS4 compatible
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
26 1
    );
27 1
28
    /**
29 1
     * @param FieldList $fields
30 1
     */
31 1
    public function updateCMSFields(FieldList $fields)
32
    {
33 1
        $image = UploadField::create('Image')
34
            //->setFolderName('Uploads/Blocks/Content')
35 1
        ;
36 1
        $fields->insertBefore($image, 'Content');
0 ignored issues
show
Documentation introduced by
'Content' is of type string, but the function expects a object<SilverStripe\Forms\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...
37
38
        /* // todo readd once Linkable is SS4 compatible
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
39
        $fields->addFieldToTab(
40
            'Root.Main',
41
            LinkField::create('BlockLinkID', 'Link'),
42
            'Image'
43
        );
44
        */
45
46
        $fields->insertAfter(TextField::create('SubTitle'), 'Title');
0 ignored issues
show
Documentation introduced by
'Title' is of type string, but the function expects a object<SilverStripe\Forms\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...
47
    }
48
49
}