Passed
Push — feature/Logging ( f3941b...f314df )
by Simon
06:52
created

SolrLog::getLastErrorLine()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
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 = [
1 ignored issue
show
introduced by
The private property $summary_fields is not used, and could be removed.
Loading history...
32
        'Timestamp',
33
        'Index',
34
        'Type',
35
        'Level'
36
    ];
37
38
    private static $searchable_fields = [
1 ignored issue
show
introduced by
The private property $searchable_fields is not used, and could be removed.
Loading history...
39
        'Created',
40
        'Index',
41
        'Type',
42
        'Level'
43
    ];
44
45
    private static $indexes = [
1 ignored issue
show
introduced by
The private property $indexes is not used, and could be removed.
Loading history...
46
        'Timestamp' => true,
47
    ];
48
49
    private static $sort = 'Created DESC';
1 ignored issue
show
introduced by
The private property $sort is not used, and could be removed.
Loading history...
50
51
    /**
52
     * @return mixed
53
     */
54
    public function getLastErrorLine()
55
    {
56
        $lines = explode("\n", $this->Message);
57
58
        return $lines[0];
59
    }
60
61
    /**
62
     * @param null|Member $member
63
     * @return bool|mixed
64
     */
65
    public function canCreate($member = null, $context = [])
66
    {
67
        return false;
68
    }
69
70
    /**
71
     * @param null|Member $member
72
     * @return bool|mixed
73
     */
74
    public function canEdit($member = null)
75
    {
76
        return false;
77
    }
78
79
    /**
80
     * @param null|Member $member
81
     * @return bool|mixed
82
     */
83 26
    public function canView($member = null)
84
    {
85 26
        return parent::canView($member);
86
    }
87
88
    /**
89
     * @param null|Member $member
90
     * @return bool|mixed
91
     */
92
    public function canDelete($member = null)
93
    {
94
        if ($member) {
95
            return $member->inGroup('administrators') || Director::isDev();
96
        }
97
98
        return parent::canDelete($member) || Director::isDev();
99
    }
100
}
101