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

CallToActionBlock::singular_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 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Dynamic\DynamicBlocks\Block;
4
5
use SheaDawson\Blocks\Model\Block;
6
7
class CallToActionBlock extends Block
8 12
{
9
    /**
10 12
     * @return string
11
     */
12
    public function singular_name()
13
    {
14
        return _t('CallToActionBlock.SINGULARNAME', 'Call To Action Block');
15
    }
16 1
17
    /**
18 1
     * @return string
19
     */
20
    public function plural_name()
21
    {
22
        return _t('CallToActionBlock.PLURALNAME', 'Call To Action Blocks');
23
    }
24
25
    /**
26
     * @var array
27
     */
28
    private static $has_one = [
29
        //'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...
30
    ];
31 1
32
    /**
33 1
     * @return FieldList
34 1
     */
35 1
    public function getCMSFields()
36 1
    {
37 1
        $this->beforeUpdateCMSFields(function ($fields) {
0 ignored issues
show
Unused Code introduced by
The parameter $fields is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38 1
39
            /* // 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...
40 1
            $fields->addFieldToTab(
41
                'Root.Main',
42 1
                LinkField::create('BlockLinkID', 'Link')
43 1
            );
44 1
            */
45
        });
46 1
47
        $fields = parent::getCMSFields();
48
49
        $fields->removeByName([
50
            'Title',
51
        ]);
52 2
53
        return $fields;
54 2
    }
55 2
56
    /**
57
     * @return mixed
58
     */
59
    public function getTitle()
60
    {
61
        if ($this->BlockLink()) {
0 ignored issues
show
Documentation Bug introduced by
The method BlockLink does not exist on object<Dynamic\DynamicBl...lock\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...
62
            return $this->BlockLink()->Title;
0 ignored issues
show
Documentation Bug introduced by
The method BlockLink does not exist on object<Dynamic\DynamicBl...lock\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...
63
        }
64
    }
65
}