FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sentry-php/src/Severity.php at source-frame-cache · getsentry/sentry-php · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
getsentry
/
sentry-php
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
475
Star
1.9k
Code
Issues
20
Pull requests
11
Discussions
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
sentry-php
/
src
/
Severity.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
171 lines (152 loc) · 3.95 KB
Breadcrumbs
sentry-php
/
src
/
Severity.php
Copy path
File metadata and controls
171 lines (152 loc) · 3.95 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
declare
(strict_types=
1
);
namespace
Sentry
;
/**
* This class represents an enum of severity levels an event can be associated
* to.
*
* @author Stefano Arlandini <sarlandini@alice.it>
*/
final
class
Severity
implements
\Stringable
{
/**
* This constant represents the "debug" severity level.
*
* @internal
*/
public
const
DEBUG
=
'
debug
'
;
/**
* This constant represents the "info" severity level.
*
* @internal
*/
public
const
INFO
=
'
info
'
;
/**
* This constant represents the "warning" severity level.
*
* @internal
*/
public
const
WARNING
=
'
warning
'
;
/**
* This constant represents the "error" severity level.
*
* @internal
*/
public
const
ERROR
=
'
error
'
;
/**
* This constant represents the "fatal" severity level.
*
* @internal
*/
public
const
FATAL
=
'
fatal
'
;
/**
* This constant contains the list of allowed enum values.
*
* @internal
*/
public
const
ALLOWED_SEVERITIES
= [
self
::
DEBUG
,
self
::
INFO
,
self
::
WARNING
,
self
::
ERROR
,
self
::
FATAL
,
];
/**
* @var string The value of this enum instance
*/
private
$
value
;
/**
* Constructor.
*
* @param string $value The value this instance represents
*/
public
function
__construct
(
string
$
value
=
self
::
INFO
)
{
if
(!
\in_array
(
$
value
,
self
::
ALLOWED_SEVERITIES
,
true
)) {
throw
new
\
InvalidArgumentException
(
\sprintf
(
'
The "%s" is not a valid enum value.
'
,
$
value
));
}
$
this
->
value
=
$
value
;
}
/**
* Translate a PHP Error constant into a Sentry log level group.
*
* @param int $severity PHP E_* error constant
*/
public
static
function
fromError
(
int
$
severity
):
self
{
switch
(
$
severity
) {
case
\
E_DEPRECATED
:
case
\
E_USER_DEPRECATED
:
case
\
E_WARNING
:
case
\
E_USER_WARNING
:
return
self
::
warning
();
case
\
E_ERROR
:
case
\
E_PARSE
:
case
\
E_CORE_ERROR
:
case
\
E_CORE_WARNING
:
case
\
E_COMPILE_ERROR
:
case
\
E_COMPILE_WARNING
:
return
self
::
fatal
();
case
\
E_RECOVERABLE_ERROR
:
case
\
E_USER_ERROR
:
return
self
::
error
();
case
\
E_NOTICE
:
case
\
E_USER_NOTICE
:
case
2048
:
// This is \E_STRICT which has been deprecated in PHP 8.4 so we should not reference it directly to prevent deprecation notices
return
self
::
info
();
default
:
return
self
::
error
();
}
}
/**
* Creates a new instance of this enum for the "debug" value.
*/
public
static
function
debug
():
self
{
return
new
self
(
self
::
DEBUG
);
}
/**
* Creates a new instance of this enum for the "info" value.
*/
public
static
function
info
():
self
{
return
new
self
(
self
::
INFO
);
}
/**
* Creates a new instance of this enum for the "warning" value.
*/
public
static
function
warning
():
self
{
return
new
self
(
self
::
WARNING
);
}
/**
* Creates a new instance of this enum for the "error" value.
*/
public
static
function
error
():
self
{
return
new
self
(
self
::
ERROR
);
}
/**
* Creates a new instance of this enum for the "fatal" value.
*/
public
static
function
fatal
():
self
{
return
new
self
(
self
::
FATAL
);
}
/**
* Returns whether two object instances of this class are equal.
*
* @param self $other The object to compare
*/
public
function
isEqualTo
(
self
$
other
):
bool
{
return
$
this
->
value
=== (
string
)
$
other
;
}
/**
* @see https://www.php.net/manual/en/language.oop5.magic.php#object.tostring
*/
public
function
__toString
():
string
{
return
$
this
->
value
;
}
}
Back
|
FazBrowse Home
|
New Git URL