MyTwitterData::canDelete()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SunnysideUp\ShareThis;
4
5
use SilverStripe\Core\Config\Config;
6
use SilverStripe\Security\Permission;
7
use SilverStripe\ORM\DataObject;
8
9
/**
10
 * MyTwitterData
11
 */
12
class MyTwitterData extends DataObject
13
{
14
    /**
15
     * @var string
16
     */
17
    private static $table_name = 'MyTwitterData';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
18
19
    /**
20
     * @var string
21
     */
22
    private static $username = "";
0 ignored issues
show
introduced by
The private property $username is not used, and could be removed.
Loading history...
23
24
    /**
25
     * @var array
26
     */
27
    private static $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
28
        "Date" => "Datetime",
29
        "TwitterID" => "Varchar(64)",
30
        "Title" => "HTMLText",
31
        "Hide" => "Boolean"
32
    ];
33
34
    /**
35
     * @var array
36
     */
37
    private static $summary_fields = [
0 ignored issues
show
introduced by
The private property $summary_fields is not used, and could be removed.
Loading history...
38
        "Date" => "Date",
39
        "Title" => "Title",
40
        "HideNice" => "Hide"
41
    ];
42
43
    /**
44
     * @var array
45
     */
46
    private static $indexes = [
0 ignored issues
show
introduced by
The private property $indexes is not used, and could be removed.
Loading history...
47
        "TwitterID" => true
48
    ];
49
50
    /**
51
     * @var array
52
     */
53
    private static $casting = [
0 ignored issues
show
introduced by
The private property $casting is not used, and could be removed.
Loading history...
54
        "Link" => "Varchar",
55
        "HideNice" => "Varchar"
56
    ];
57
58
    /**
59
     * @var string
60
     */
61
    private static $default_sort = "\"Date\" DESC";
0 ignored issues
show
introduced by
The private property $default_sort is not used, and could be removed.
Loading history...
62
63
    /**
64
     * @return string
65
     */
66
    public function forTemplate()
67
    {
68
        return $this->Title;
69
    }
70
71
    /**
72
     * @return string
73
     */
74
    public function Link()
75
    {
76
        return "https://twitter.com/".Config::inst()->get(MyTwitterData::class, "username")."/status/".$this->TwitterID;
0 ignored issues
show
Bug Best Practice introduced by
The property TwitterID does not exist on SunnysideUp\ShareThis\MyTwitterData. Since you implemented __get, consider adding a @property annotation.
Loading history...
77
    }
78
79
    /**
80
     * @return boolean
81
     */
82
    public function canView($member = null)
83
    {
84
        return Permission::checkMember($member, 'SOCIAL_MEDIA');
85
    }
86
87
    /**
88
     * @return boolean
89
     */
90
    public function canCreate($member = null, $context = [])
91
    {
92
        return false;
93
    }
94
95
    /**
96
     * @return boolean
97
     */
98
    public function canEdit($member = null)
99
    {
100
        return Permission::checkMember($member, 'SOCIAL_MEDIA');
101
    }
102
103
    /**
104
     * @return boolean
105
     */
106
    public function canDelete($member = null)
107
    {
108
        return false;
109
    }
110
111
    /**
112
     * @return boolean
113
     */
114
    public function HideNice()
115
    {
116
        return $this->dbObject('Hide')->Nice();
117
    }
118
}
119