forked from php-censor/php-censor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuildError.php
More file actions
109 lines (91 loc) · 2.44 KB
/
Copy pathBuildError.php
File metadata and controls
109 lines (91 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
namespace PHPCensor\Model;
use PHPCensor\Model\Base\BuildError as BaseBuildError;
use PHPCensor\Store\BuildStore;
use PHPCensor\Store\Factory;
class BuildError extends BaseBuildError
{
/**
* @return Build|null
*/
public function getBuild()
{
$buildId = $this->getBuildId();
if (empty($buildId)) {
return null;
}
/** @var BuildStore $buildStore */
$buildStore = Factory::getStore('Build');
return $buildStore->getById($buildId);
}
/**
* Get the language string key for this error's severity level.
*
* @return string
*/
public function getSeverityString()
{
switch ($this->getSeverity()) {
case self::SEVERITY_CRITICAL:
return 'critical';
case self::SEVERITY_HIGH:
return 'high';
case self::SEVERITY_NORMAL:
return 'normal';
case self::SEVERITY_LOW:
return 'low';
}
}
/**
* Get the language string key for this error's severity level.
*
* @param int $severity
*
* @return string
*/
public static function getSeverityName($severity)
{
switch ($severity) {
case self::SEVERITY_CRITICAL:
return 'critical';
case self::SEVERITY_HIGH:
return 'high';
case self::SEVERITY_NORMAL:
return 'normal';
case self::SEVERITY_LOW:
return 'low';
}
}
/**
* @param string $plugin
* @param string $file
* @param int $lineStart
* @param int $lineEnd
* @param int $severity
* @param string $message
*
* @return string
*/
public static function generateHash($plugin, $file, $lineStart, $lineEnd, $severity, $message)
{
return md5($plugin . $file . $lineStart . $lineEnd . $severity . $message);
}
/**
* Get the class to apply to HTML elements representing this error.
*
* @return string
*/
public function getSeverityClass()
{
switch ($this->getSeverity()) {
case self::SEVERITY_CRITICAL:
return 'danger';
case self::SEVERITY_HIGH:
return 'warning';
case self::SEVERITY_NORMAL:
return 'info';
case self::SEVERITY_LOW:
return 'default';
}
}
}