BlogCategory::getListUrlSegment()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

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