Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
/*
4
 * This file is part of Psy Shell.
5
 *
200 lars 6
 * (c) 2012-2023 Justin Hileman
148 lars 7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
 
12
namespace Psy\Util;
13
 
14
/**
15
 * A static class to wrap JSON encoding/decoding with PsySH's default options.
16
 */
17
class Json
18
{
19
    /**
20
     * Encode a value as JSON.
21
     *
22
     * @param mixed $val
23
     * @param int   $opt
24
     */
25
    public static function encode($val, int $opt = 0): string
26
    {
27
        $opt |= \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE;
28
 
29
        return \json_encode($val, $opt);
30
    }
31
}