Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12297470
Log.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
Log.php
View Options
<?php
namespace
Nasqueron\Api\ServersLog
;
class
Log
{
/**
* @var LogEntry[]
*/
private
$entries
=
[];
public
function
add
(
LogEntry
$entry
)
:
void
{
$this
->
entries
[]
=
$entry
;
}
public
function
getAll
()
:
array
{
return
$this
->
entries
;
}
public
function
toJSON
()
:
string
{
return
json_encode
(
$this
->
entries
,
JSON_PRETTY_PRINT
);
}
public
function
fillFromJSON
(
string
$json
)
:
void
{
$entries
=
json_decode
(
$json
);
foreach
(
$entries
as
$entry
)
{
$this
->
add
(
LogEntry
::
fromJSON
(
$entry
));
}
}
///
/// Static helper methods
///
public
static
function
loadFromJSONFile
(
string
$filename
)
:
Log
{
$log
=
new
Log
;
$json
=
file_get_contents
(
$filename
);
$log
->
fillFromJSON
(
$json
);
return
$log
;
}
public
static
function
addEntryToJSONFile
(
string
$filename
,
LogEntry
$entry
)
:
void
{
$log
=
self
::
loadFromJSONFile
(
$filename
);
$log
->
add
(
$entry
);
file_put_contents
(
$filename
,
$log
->
toJSON
());
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Oct 22, 12:08 (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3092089
Default Alt Text
Log.php (1 KB)
Attached To
Mode
rAPISRVLOGS Servers log :: Add new entries API
Attached
Detach File
Event Timeline
Log In to Comment