Completed
Pull Request — master (#62)
by Jason
12:32
created

EmbedCodeBlock   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 47
loc 47
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A singular_name() 4 4 1
A plural_name() 4 4 1
A getCMSFields() 12 12 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
use SilverStripe\Forms\TextareaField;
7
8
/**
9
 * Class EmbedCodeBlock
10
 */
11 View Code Duplication
class EmbedCodeBlock 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...
12
{
13
14
    /**
15
     * @return string
16
     */
17
    public function singular_name()
18
    {
19
        return _t('EmbedCodeBlock.SINGULARNAME', 'Embed Code Block');
20
    }
21
22
    /**
23
     * @return string
24
     */
25
    public function plural_name()
26
    {
27
        return _t('EmbedCodeBlock.PLURALNAME', 'Embed Code Blocks');
28
    }
29
    /**
30
     * @var string
31
     */
32
    private static $description = 'Block providing ability to embed code (generally javascript)';
33
34
    /**
35
     * @var array
36
     */
37
    private static $db = [
38
        'Code' => 'HTMLText',
39
    ];
40
41
    /**
42
     * @return \FieldList
43
     */
44
    public function getCMSFields()
45
    {
46
        $fields = parent::getCMSFields();
47
48
        $fields->replaceField(
49
            'Code',
50
            TextareaField::create('Code')
51
                ->setTitle('Embed Code')
52
        );
53
54
        return $fields;
55
    }
56
57
}