Subversion-Projekte lars-tiefland.laravel_shop

Revision

Zur aktuellen Revision | Details | 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
 *
6
 * (c) 2012-2022 Justin Hileman
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
     * @return string
26
     */
27
    public static function encode($val, int $opt = 0): string
28
    {
29
        $opt |= \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE;
30
 
31
        return \json_encode($val, $opt);
32
    }
33
}