toArray(); } try { $json = json_encode($data, $flags | JSON_THROW_ON_ERROR, $depth); } catch (Throwable $exception) { throw new InvalidArgumentException($exception->getMessage(), (int) $exception->getCode(), $exception); } return $json; } /** * @throws InvalidArgumentException */ public static function decode(string $json, bool $assoc = true, int $depth = 512, int $flags = 0): mixed { try { $decode = json_decode($json, $assoc, $depth, $flags | JSON_THROW_ON_ERROR); } catch (Throwable $exception) { throw new InvalidArgumentException($exception->getMessage(), (int) $exception->getCode(), $exception); } return $decode; } }