Passed
Push — hans/logtests ( 76c086...71695d )
by Simon
06:24 queued 02:27
created

SolrLog::canCreate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
4
namespace Firesphere\SolrSearch\Models;
5
6
use SilverStripe\Control\Director;
7
use SilverStripe\ORM\DataObject;
8
use SilverStripe\Security\Member;
9
10
/**
11
 * Class \Firesphere\SolrSearch\Models\SolrError
12
 *
13
 * @property string $Timestamp
14
 * @property string $Message
15
 * @property string $Index
16
 * @property string $Type
17
 * @property string $Level
18
 */
19
class SolrLog extends DataObject
20
{
21
    private static $table_name = 'SolrLog';
22
23
    private static $db = [
24
        'Timestamp' => 'Varchar(50)',
25
        'Message'   => 'Text',
26
        'Index'     => 'Varchar(255)',
27
        'Type'      => 'Enum("Config,Index,Query")',
28
        'Level'     => 'Varchar(10)'
29
    ];
30
31
    private static $summary_fields = [
32
        'Timestamp',
33
        'Index',
34
        'Type',
35
        'Level'
36
    ];
37
38
    private static $searchable_fields = [
39
        'Created',
40
        'Index',
41
        'Type',
42
        'Level'
43
    ];
44
45
    private static $indexes = [
46
        'Timestamp' => true,
47
    ];
48
49
    private static $sort = 'Created DESC';
50
51
    /**
52
     * @return mixed
53
     */
54 1
    public function getLastErrorLine()
55
    {
56 1
        $lines = explode(PHP_EOL, $this->Message);
57
58 1
        return $lines[0];
59
    }
60
61
    /**
62
     * @param null|Member $member
63
     * @return bool|mixed
64
     */
65 1
    public function canCreate($member = null, $context = [])
66
    {
67 1
        return false;
68
    }
69
70
    /**
71
     * @param null|Member $member
72
     * @return bool|mixed
73
     */
74 1
    public function canEdit($member = null)
75
    {
76 1
        return false;
77
    }
78
79
    /**
80
     * @param null|Member $member
81
     * @return bool|mixed
82
     */
83 29
    public function canView($member = null)
84
    {
85 29
        return parent::canView($member);
86
    }
87
88
    /**
89
     * @param null|Member $member
90
     * @return bool|mixed
91
     */
92 1
    public function canDelete($member = null)
93
    {
94 1
        if ($member) {
95
            return $member->inGroup('administrators') || Director::isDev();
96
        }
97
98 1
        return parent::canDelete($member) || Director::isDev();
99
    }
100
}
101