Completed
Push — master ( bab916...1c5f6e )
by Jason
10:56
created

EmbedBlock::getCMSFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 14
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 0
Metric Value
dl 14
loc 14
ccs 10
cts 10
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
crap 1
1
<?php
2
3 View Code Duplication
class EmbedBlock extends Block
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
4
{
5
    /**
6
     * @return string
7
     */
8 13
    public function singular_name()
9
    {
10 13
        return _t('AccordionBlock.SINGULARNAME', 'Embed Block');
11
    }
12
13
    /**
14
     * @return string
15
     */
16
    public function plural_name()
17
    {
18
        return _t('AccordionBlock.PLURALNAME', 'Embed Blocks');
19
    }
20
21
    /**
22
     * @var array
23
     */
24
    private static $has_one = [
25
        'EmbeddedObject' => 'EmbeddedObject',
26
    ];
27
28
    /**
29
     * @return FieldList
30
     */
31 1
    public function getCMSFields(){
32 1
        $fields = parent::getCMSFields();
33
34 1
        $fields->removeByName([
35 1
            'EmbeddedObjectID',
36 1
        ]);
37
38 1
        $fields->addFieldToTab(
39 1
            'Root.Embed',
40 1
            EmbeddedObjectField::create('EmbeddedObject', 'Content from oEmbed URL', $this->EmbeddedObject())
0 ignored issues
show
Documentation Bug introduced by
The method EmbeddedObject does not exist on object<EmbedBlock>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
41 1
        );
42
43 1
        return $fields;
44
    }
45
}