Completed
Pull Request — master (#62)
by Jason
02:27
created

CallToActionBlock   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 95%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 61
loc 61
ccs 19
cts 20
cp 0.95
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A singular_name() 4 4 1
A plural_name() 4 4 1
A getCMSFields() 20 20 1
A getTitle() 8 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Dynamic\DynamicBlocks\Block;
4
5
use SheaDawson\Blocks\Model\Block;
6
7 View Code Duplication
class CallToActionBlock 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...
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
        /* // todo readd once Linkable is SS4 compatible
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% 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...
62
        if ($this->BlockLink()) {
63
            return $this->BlockLink()->Title;
64
        }
65
        */
66
    }
67
}