+ /**
+ * Retrieve metadata of the currently running phar
+ * @param string $key
+ * @return mixed
+ */
+ public function metadata($key = null) {
+ $running = new Phar(Phar::running(false));
+
+ 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;
+ }
+