Example #1
0
 /**
  * @param RequestedPhar $requestedPhar
  *
  * @throws DownloadFailedException
  * @throws ResolveException
  *
  * @return Release
  */
 private function getRelease(RequestedPhar $requestedPhar)
 {
     if ($requestedPhar->isAlias()) {
         return $this->resolveAlias($requestedPhar->getAlias());
     }
     return new Release($this->getPharVersion($requestedPhar->getPharUrl()), $requestedPhar->getPharUrl(), null);
 }
 public function testCreatesInstanceFromAlias()
 {
     $alias = new PharAlias('foo', new AnyVersionConstraint());
     $phar = RequestedPhar::fromAlias($alias);
     $this->assertInstanceOf(RequestedPhar::class, $phar);
     $this->assertTrue($phar->isAlias());
     $this->assertSame($alias, $phar->getAlias());
 }
Example #3
0
 /**
  * @return RequestedPhar[]
  */
 public function getPhars()
 {
     $phars = [];
     /** @var \DOMElement $pharNode */
     foreach ($this->getXPath()->query('//phive:phar') as $pharNode) {
         if ($pharNode->hasAttribute('url')) {
             $phars[] = RequestedPhar::fromUrl(new Url($pharNode->getAttribute('url')));
         } else {
             $phars[] = RequestedPhar::fromAlias($this->getPharAliasFromNode($pharNode));
         }
     }
     return $phars;
 }