Settings   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 60
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getNativemailerLevelOptions() 0 4 1
A getSlackLevelOptions() 0 4 1
A getSyslogLevelOptions() 0 4 1
A getNewrelicLevelOptions() 0 4 1
A getErrorLevelOptions() 0 13 1
1
<?php
2
3
namespace VojtaSvoboda\ErrorLogger\Models;
4
5
use October\Rain\Database\Model;
6
use October\Rain\Database\Traits\Validation as ValidationTrait;
7
8
class Settings extends Model
9
{
10
    use ValidationTrait;
11
12
    public $implement = ['System.Behaviors.SettingsModel'];
13
14
    // A unique code
15
    public $settingsCode = 'vojtasvoboda_errorlogger_settings';
16
17
    // Reference to field configuration
18
    public $settingsFields = 'fields.yaml';
19
20
    public $rules = [
21
        'nativemailer_email' => 'required_if:nativemailer_enabled,1',
22
        'slack_token' => 'required_if:slack_enabled,1',
23
        'slack_channel' => 'required_if:slack_enabled,1',
24
        'slack_username' => 'required_if:slack_enabled,1',
25
        'syslog_ident' => 'required_if:syslog_enabled,1',
26
        'syslog_facility' => 'required_if:syslog_enabled,1',
27
        'newrelic_appname' => 'required_if:newrelic_enabled,1',
28
    ];
29
30
    public $attributeNames = [
31
        'nativemailer_email' => 'Developer email',
32
    ];
33
34
    public static function getNativemailerLevelOptions()
35
    {
36
        return self::getErrorLevelOptions();
37
    }
38
39
    public static function getSlackLevelOptions()
40
    {
41
        return self::getErrorLevelOptions();
42
    }
43
44
    public static function getSyslogLevelOptions()
45
    {
46
        return self::getErrorLevelOptions();
47
    }
48
49
    public static function getNewrelicLevelOptions()
50
    {
51
        return self::getErrorLevelOptions();
52
    }
53
54
    public static function getErrorLevelOptions()
55
    {
56
        return [
57
            100 => 'Debug - Level 100 - Detailed debug information',
58
            200 => 'Info - Level 200 - Interesting events e.g. user logs in, SQL logs',
59
            250 => 'Notice - Level 250 - Uncommon events',
60
            300 => 'Warning - Level 300 - Exceptional occurrences that are not errors',
61
            400 => 'Error - Level 400 - Runtime errors',
62
            500 => 'Critical - Level 500 - Critical conditions',
63
            550 => 'Alert - Level 550 - Action must be taken immediately',
64
            600 => 'Emergency - Level 600 - Urgent alert'
65
        ];
66
    }
67
}
68