public function extract($name = 'new', $result = null)
{
$from = 'app';
$to = $name;
if ($result) {
$from = $name;
$to = $result;
}
$to = $this->_toPath($to);
if ($from[0] !== '/') {
$from = Libraries::locate('command.create.template', $from, array('filter' => false, 'type' => 'file', 'suffix' => '.phar.gz'));
if (!$from || is_array($from)) {
return false;
}
}
if (file_exists($from)) {
try {
$archive = new Phar($from);
} catch (Exception $e) {
$this->error($e->getMessage());
return false;
}
if ($archive->extractTo($to)) {
$this->out(basename($to) . " created in " . dirname($to) . " from {$from}");
return true;
}
}
$this->error("Could not extract {$to} from {$from}");
return false;
}