public static function dump($data, $path, $options = 0, $depth = 512)
    {
        $json = self::encode($data, $options, $depth);

        $result = file_put_contents($path, $json);
        if ($result === false) {
            $error = error_get_last();
            throw new \Exception("Failed writing JSON data to file: " . $error['message']);
        }

        return $result;
    }