/**
* Retrieve metadata of the currently running phar
* @param string $key
* @return mixed
*/
public function metadata($key = null)
{
if (extension_loaded("Phar")) {
$running = new Phar(Phar::running(false));
} else {
$running = new Archive(PHAREXT_PHAR);
}
if ($key === "signature") {
$sig = $running->getSignature();
return sprintf("%s signature of %s\n%s", $sig["hash_type"], $this->metadata("name"), chunk_split($sig["hash"], 64, "\n"));
}
$metadata = $running->getMetadata();
if (isset($key)) {
return $metadata[$key];
}
return $metadata;
}