Completed
Push — master ( 6815df...d4e03c )
by Jason
05:43
created

CallToActionBlock::plural_name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
class CallToActionBlock extends Block
4
{
5
    /**
6
     * @return string
7
     */
8 9
    public function singular_name()
9
    {
10 9
        return _t('CallToActionBlock.SINGULARNAME', 'Call To Action Block');
11
    }
12
13
    /**
14
     * @return string
15
     */
16
    public function plural_name()
17
    {
18
        return _t('CallToActionBlock.PLURALNAME', 'Call To Action Blocks');
19
    }
20
21
    /**
22
     * @var array
23
     */
24
    private static $has_one = [
25
        'BlockLink' => 'Link',
26
    ];
27
28
    /**
29
     * @return FieldList
30
     */
31 1
    public function getCMSFields()
32
    {
33 1
        $this->beforeUpdateCMSFields(function ($fields) {
34 1
            $fields->addFieldToTab(
35 1
                'Root.Main',
36 1
                LinkField::create('BlockLinkID', 'Link')
37 1
            );
38 1
        });
39
40 1
        $fields = parent::getCMSFields();
41
42 1
        $fields->removeByName([
43 1
            'Title',
44 1
        ]);
45
46 1
        return $fields;
47
    }
48
49 1
    public function getTitle()
50
    {
51 1
        if ($this->BlockLink()) {
0 ignored issues
show
Documentation Bug introduced by
The method BlockLink does not exist on object<CallToActionBlock>? 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...
52 1
            return $this->BlockLink()->Title;
0 ignored issues
show
Documentation Bug introduced by
The method BlockLink does not exist on object<CallToActionBlock>? 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...
53
        }
54
    }
55
}