Completed
Pull Request — master (#421)
by Robbie
03:13 queued 52s
created

BlogCategory::getDuplicateError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace SilverStripe\Blog\Model;
4
5
use SilverStripe\Blog\Model\Blog;
6
use SilverStripe\Blog\Model\BlogObject;
7
use SilverStripe\Blog\Model\BlogPost;
8
use SilverStripe\Blog\Model\CategorisationObject;
9
use SilverStripe\ORM\DataObject;
10
11
/**
12
 * A blog category for generalising blog posts.
13
 *
14
 * @package silverstripe
15
 * @subpackage blog
16
 *
17
 * @method Blog Blog()
18
 *
19
 * @property string $Title
20
 * @property string $URLSegment
21
 * @property int $BlogID
22
 */
23 View Code Duplication
class BlogCategory extends DataObject implements CategorisationObject
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...
24
{
25
    use BlogObject;
26
27
    /**
28
     * Use an exception code so that attempted writes can continue on
29
     * duplicate errors.
30
     *
31
     * @const string
32
     * This must be a string because ValidationException has decided we can't use int
33
     */
34
    const DUPLICATE_EXCEPTION = 'DUPLICATE';
35
36
    /**
37
     * {@inheritDoc}
38
     * @var string
39
     */
40
    private static $table_name = 'BlogCategory';
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 $table_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...
41
42
    /**
43
     * @var array
44
     */
45
    private static $db = array(
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...
46
        'Title'      => 'Varchar(255)',
47
        'URLSegment' => 'Varchar(255)'
48
    );
49
50
    /**
51
     * @var array
52
     */
53
    private static $has_one = array(
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...
54
        'Blog' => Blog::class,
55
    );
56
57
    /**
58
     * @var array
59
     */
60
    private static $belongs_many_many = array(
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 $belongs_many_many 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...
61
        'BlogPosts' => BlogPost::class,
62
    );
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    protected function getListUrlSegment()
68
    {
69
        return 'category';
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     */
75
    protected function getDuplicateError()
76
    {
77
        return _t('BlogCategory.Duplicate', 'A blog category already exists with that name.');
78
    }
79
}
80