public static function reset()
    {
        static::$_formats = [];

        static::set('html', ['text/html', 'application/xhtml+xml']);
        static::set('xml', ['text/xml', 'application/xml']);
        static::set('text', ['text/plain']);

        static::set('json', ['application/json'], [
            'encode' => function($data, $options = []) {
                $defaults = [
                    'depth' => 512,
                    'flag'  => 0
                ];
                $options += $defaults;

                if (!empty($options['errors'])) {
                    $error = reset($options['errors']);
                    $data = [
                        'error' => [
                            'code' => $error->getCode(),
                            'title' => $error->getMessage(),
                            'trace' => explode("\n", $error->getTraceAsString())
                        ]
                    ];
                }

                $result = json_encode($data, $options['flag'], $options['depth']);
                if (json_last_error() !== JSON_ERROR_NONE) {
                    throw new InvalidArgumentException(json_last_error_msg());
                }
                return $result;
            },
            'decode' => function($data, $options = []) {
                $defaults = [
                    'array' => true,
                    'depth' => 512,
                    'flag'  => 0
                ];
                $options += $defaults;
                $result = json_decode($data, $options['array'], $options['depth'], $options['flag']);

                if (json_last_error() !== JSON_ERROR_NONE) {
                    throw new InvalidArgumentException("Invalid JSON, can't decode `'{$data}'``: ". json_last_error_msg());
                }
                return $result;
            }
        ]);

        static::set('form', ['application/x-www-form-urlencoded'], [
            'encode' => 'http_build_query',
            'decode' => function($data) {
                $decoded = array();
                parse_str($data, $decoded);
                return $decoded;
            }
        ]);
    }
public static function reset()
    {
        static::$_formats = [];

        static::set('html', ['text/html', 'application/xhtml+xml']);
        static::set('xml', ['text/xml', 'application/xml']);
        static::set('text', ['text/plain']);

        static::set('json', ['application/json'], [
            'encode' => function($data, $options = []) {
                $defaults = [
                    'depth' => 512,
                    'flag'  => 0
                ];
                $options += $defaults;

                if (!empty($options['errors'])) {
                    $error = reset($options['errors']);
                    $data = [
                        'error' => [
                            'code' => $error->getCode(),
                            'title' => $error->getMessage(),
                            'trace' => explode("\n", $error->getTraceAsString())
                        ]
                    ];
                }

                $result = json_encode($data, $options['flag'], $options['depth']);
                if (json_last_error() !== JSON_ERROR_NONE) {
                    throw new InvalidArgumentException(json_last_error_msg());
                }
                return $result;
            },
            'decode' => function($data, $options = []) {
                $defaults = [
                    'array' => true,
                    'depth' => 512,
                    'flag'  => 0
                ];
                $options += $defaults;
                $result = json_decode($data, $options['array'], $options['depth'], $options['flag']);

                if (json_last_error() !== JSON_ERROR_NONE) {
                    throw new InvalidArgumentException("Invalid JSON, can't decode `'{$data}'``: ". json_last_error_msg());
                }
                return $result;
            }
        ]);

        static::set('form', ['application/x-www-form-urlencoded'], [
            'encode' => 'http_build_query',
            'decode' => function($data) {
                $decoded = array();
                parse_str($data, $decoded);
                return $decoded;
            }
        ]);
    }
public static function reset ( ) { static :: $ _formats = [ ] ; static :: set ( 'html' , [ 'text/html' , 'application/xhtml+xml' ] ) ; static :: set ( 'xml' , [ 'text/xml' , 'application/xml' ] ) ; static :: set ( 'text' , [ 'text/plain' ] ) ; static :: set ( 'json' , [ 'application/json' ] , [ 'encode' => function ( $ data , $ options = [ ] ) { $ defaults = [ 'depth' => 512 , 'flag' => 0 ] ; $ options += $ defaults ; if ( ! empty ( $ options [ 'errors' ] ) ) { $ error = reset ( $ options [ 'errors' ] ) ; $ data = [ 'error' => [ 'code' => $ error -> getCode ( ) , 'title' => $ error -> getMessage ( ) , 'trace' => explode ( "\n" , $ error -> getTraceAsString ( ) ) ] ] ; } $ result = json_encode ( $ data , $ options [ 'flag' ] , $ options [ 'depth' ] ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { throw new InvalidArgumentException ( json_last_error_msg ( ) ) ; } return $ result ; } , 'decode' => function ( $ data , $ options = [ ] ) { $ defaults = [ 'array' => true , 'depth' => 512 , 'flag' => 0 ] ; $ options += $ defaults ; $ result = json_decode ( $ data , $ options [ 'array' ] , $ options [ 'depth' ] , $ options [ 'flag' ] ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { throw new InvalidArgumentException ( "Invalid JSON, can't decode `'{$data}'``: " . json_last_error_msg ( ) ) ; } return $ result ; } ] ) ; static :: set ( 'form' , [ 'application/x-www-form-urlencoded' ] , [ 'encode' => 'http_build_query' , 'decode' => function ( $ data ) { $ decoded = array ( ) ; parse_str ( $ data , $ decoded ) ; return $ decoded ; } ] ) ; }
Resets the `Media` class.
Resets the Media class .