namespace pharext\Cli;
use pharext\Archive;
+use pharext\Metadata;
use Phar;
{
/**
* Command line arguments
- * @var pharext\Cli\Args
+ * @var Args
*/
private $args;
* @return mixed
*/
public function metadata($key = null) {
- if (extension_loaded("Phar")) {
- $running = new Phar(Phar::running(false));
- } else {
- $running = new Archive(PHAREXT_PHAR);
- }
+ try {
+ 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"));
- }
+ 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();
+ $metadata = $running->getMetadata();
+ } catch (\Exception $e) {
+ $metadata = Metadata::all();
+ }
if (isset($key)) {
return $metadata[$key];
}