mirror of
https://gh.wpcy.net/https://github.com/aspirepress/AspireCloud.git
synced 2026-06-01 00:19:09 +08:00
25 lines
577 B
PHP
25 lines
577 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Values;
|
|
|
|
use Override;
|
|
|
|
/**
|
|
* In addition to adding the JSON_PRETTY_PRINT and JSON_UNESCAPED_* flags, this also sets JSON_THROW_ON_ERROR,
|
|
* which any sane consumer of this traight ought to be doing in the first place.
|
|
*/
|
|
trait ToJsonPretty
|
|
{
|
|
public const DEFAULT_FLAGS = JSON_THROW_ON_ERROR
|
|
| JSON_PRETTY_PRINT
|
|
| JSON_UNESCAPED_SLASHES
|
|
| JSON_UNESCAPED_UNICODE;
|
|
|
|
#[Override]
|
|
public function toJson($options = 0): string|false
|
|
{
|
|
return parent::toJson($options | self::DEFAULT_FLAGS);
|
|
}
|
|
}
|