/
UrlRepository.php
48 lines (41 loc) · 1.27 KB
/
UrlRepository.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php declare(strict_types=1);
/*
* This file is part of Phive.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Phive;
class UrlRepository implements SourceRepository {
/** @var null|Url */
private $url;
/** @var null|Url */
private $sigUrl;
/**
* UrlRepository constructor.
*/
public function __construct(?Url $url = null, ?Url $sigUrl = null) {
$this->url = $url;
$this->sigUrl = $sigUrl;
}
public function getReleasesByRequestedPhar(RequestedPhar $requestedPhar): ReleaseCollection {
$releases = new ReleaseCollection();
if ($this->url === null) {
return $releases;
}
if ($requestedPhar->getUrl()->equals($this->url)) {
$releases->add(
new SupportedRelease(
$requestedPhar->getUrl()->getPharName(),
$requestedPhar->getUrl()->getPharVersion(),
$requestedPhar->getUrl(),
$this->sigUrl
)
);
}
return $releases;
}
}