GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

TileSection_ContentTile   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 8
dl 0
loc 87
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getCMSFields() 0 13 1
A getCMSValidator() 0 8 1
A getTemplateName() 0 6 2
A RenderTile() 0 6 2
A TileClasses() 0 8 2
1
<?php
2
/**
3
 * Models a Content Tile for a {@link ContentBlock_TileSection}
4
 *
5
 * @since 1.0.0
6
 */
7
class TileSection_ContentTile extends DataObject
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
{
9
    private static $singular_name = 'Content Tile';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $singular_name is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
10
    private static $plural_name = 'Content Tiles';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $plural_name is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
11
12
    private static $casting = [
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $casting is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
13
        'RenderTile' => 'HTMLText'
14
    ];
15
16
    private static $db = [
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $db is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
17
        'Title' => 'Text',
18
        'Caption' => 'Text',
19
        'Sort' => 'Int'
20
    ];
21
22
    private static $has_one = [
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $has_one is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
23
        'Image' => 'Image',
24
        'Link' => 'Link',
25
        'Parent' => 'ContentBlock_TileSection',
26
    ];
27
28
    private static $default_sort = 'Sort ASC';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $default_sort is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
29
30
    public function getCMSFields()
31
    {
32
        $fields = FieldList::create([
33
            TextField::create('Title'),
34
            TextareaField::create('Caption'),
35
            UploadField::create('Image'),
36
            LinkField::create('LinkID'),
37
        ]);
38
39
        $this->extend('updateCMSFields', $fields);
40
41
        return $fields;
42
    }
43
44
    /**
45
     * @return RequiredFields
46
     */
47
    public function getCMSValidator()
48
    {
49
        return RequiredFields::create(array(
50
            'Title',
51
            'Image',
52
            'LinkID',
53
        ));
54
    }
55
56
    /**
57
     * Gets the chosen template name from the parent {@link ContentBlock_TileSection}
58
     *
59
     * @return string
60
     */
61
    public function getTemplateName()
62
    {
63
        if ($parent = $this->getComponent('Parent')) {
64
            return $parent->getField('TileTemplate');
65
        }
66
    }
67
68
    /**
69
     * Renders the Tile into the parent {@link ContentBlock_TileSection}'s chosen template
70
     *
71
     * @return string
72
     */
73
    public function RenderTile()
74
    {
75
        if ($template = $this->getTemplateName()) {
76
            return $this->renderWith($template);
77
        }
78
    }
79
80
    /**
81
     * Gets the configured classes for a row
82
     *
83
     * @return string
84
     */
85
    public function TileClasses()
86
    {
87
        $classesArray = Config::inst()->get('ContentBlock_TileSection', 'tile_classes');
88
89
        $this->extend('updateTileClasses', $classes);
90
91
        return (!empty($classesArray)) ? implode(' ', $classesArray) : '' ;
92
    }
93
}
94