Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4104627
JsonFormat.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
JsonFormat.php
View Options
<?php
namespace
MediaWiki\Settings\Source\Format
;
use
Stringable
;
use
UnexpectedValueException
;
/**
* Decodes settings data from JSON.
*/
class
JsonFormat
implements
Stringable
,
SettingsFormat
{
/**
* Decodes JSON.
*
* @param string $data JSON string to decode.
*
* @return array
* @throws UnexpectedValueException
*/
public
function
decode
(
string
$data
):
array
{
$settings
=
json_decode
(
$data
,
true
);
if
(
$settings
===
null
)
{
throw
new
UnexpectedValueException
(
'Failed to decode JSON: '
.
json_last_error_msg
()
);
}
if
(
!
is_array
(
$settings
)
)
{
throw
new
UnexpectedValueException
(
'Decoded settings must be an array'
);
}
return
$settings
;
}
/**
* Returns true for the file extension 'json'. Case insensitive.
*
* @param string $ext File extension.
*
* @return bool
*/
public
static
function
supportsFileExtension
(
string
$ext
):
bool
{
return
strtolower
(
$ext
)
==
'json'
;
}
/**
* Returns the name/type of this format (JSON).
*
* @return string
*/
public
function
__toString
():
string
{
return
'JSON'
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Aug 18, 18:33 (3 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
7f/82/64ce6e5a57ace4bbc5df5feb2ccd
Default Alt Text
JsonFormat.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment