XBRL-Signer.php
private function save_json( $json, $filename)
	{
		$extension = pathinfo( $filename, PATHINFO_EXTENSION );
		$output_basename = pathinfo( $filename, PATHINFO_FILENAME );

		if ( $extension == 'zip' )
		{
			/**
			 * @var ZipArchive $zip
			 */
			$zip = new ZipArchive();
			$zip->open( $filename, ZipArchive::CREATE );
			$zip->addFromString( "$output_basename.json", $json );

			if ( $zip->close() === false )
			{
				$message = "Error closing zip file: " . $zip->getStatusString();
				throw new \Exception( $message );
			}
		}
		else if ( $extension != 'json' )
		{
			$message = "Only files with .zip or .json extension are supported";
			throw new \Exception( $message );
		}
		else
		{
			if ( file_put_contents( $filename, $json ) === false )
			{
				$message = "Failed to write ";
				throw new \Exception( $message );
			}
		}
	}
private function save_json( $json, $filename)
	{
		$extension = pathinfo( $filename, PATHINFO_EXTENSION );
		$output_basename = pathinfo( $filename, PATHINFO_FILENAME );

		if ( $extension == 'zip' )
		{
			/**
			 * @var ZipArchive $zip
			 */
			$zip = new ZipArchive();
			$zip->open( $filename, ZipArchive::CREATE );
			$zip->addFromString( "$output_basename.json", $json );

			if ( $zip->close() === false )
			{
				$message = "Error closing zip file: " . $zip->getStatusString();
				throw new \Exception( $message );
			}
		}
		else if ( $extension != 'json' )
		{
			$message = "Only files with .zip or .json extension are supported";
			throw new \Exception( $message );
		}
		else
		{
			if ( file_put_contents( $filename, $json ) === false )
			{
				$message = "Failed to write ";
				throw new \Exception( $message );
			}
		}
	}
private function save_json ( $ json , $ filename ) { $ extension = pathinfo ( $ filename , PATHINFO_EXTENSION ) ; $ output_basename = pathinfo ( $ filename , PATHINFO_FILENAME ) ; if ( $ extension == 'zip' ) { /**
			 * @var ZipArchive $zip
			 */ $ zip = new ZipArchive ( ) ; $ zip -> open ( $ filename , ZipArchive :: CREATE ) ; $ zip -> addFromString ( "$output_basename.json" , $ json ) ; if ( $ zip -> close ( ) === false ) { $ message = "Error closing zip file: " . $ zip -> getStatusString ( ) ; throw new \ Exception ( $ message ) ; } } else if ( $ extension != 'json' ) { $ message = "Only files with .zip or .json extension are supported" ; throw new \ Exception ( $ message ) ; } else { if ( file_put_contents ( $ filename , $ json ) === false ) { $ message = "Failed to write " ; throw new \ Exception ( $ message ) ; } } }
Save the JSON to file. If the filename ends in .zip the file will be stored in a zip archive.
@param string $json The raw JSON
@param string $filename The name to use for the saved file
@throws \Exception Throws an exception if the zip file cannot be created, if the JSOn file cannot be written or if the extension is invalid
Save the JSON to file . If the filename ends in . zip the file will be stored in a zip archive .