encodingOptions = $encodingOptions; $this->decodingOptions = $decodingOptions; } public static function fromContent(mixed $content, int $encodingOptions = self::DEFAULT_JSON_ENCODING_FLAGS) : StreamInterface { if ( false === $json = json_encode($content, $encodingOptions) ) { throw new \InvalidArgumentException(sprintf('Json encoding failed with message `%s`.', json_last_error_msg())); } return static::fromJsonEncoded($json); } public static function fromJsonEncoded(string $json) : StreamInterface { $obj = static::fromTemp($json); $obj->rewind(); return $obj; } public function decode(): mixed { $content = $this->getContents(); if ($content === "") { return null; } return json_decode($content, true, $this->depth, $this->decodingOptions); } }