| 148 |
lars |
1 |
<?php declare(strict_types = 1);
|
|
|
2 |
/*
|
|
|
3 |
* This file is part of PharIo\Manifest.
|
|
|
4 |
*
|
|
|
5 |
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
|
|
6 |
*
|
|
|
7 |
* For the full copyright and license information, please view the LICENSE
|
|
|
8 |
* file that was distributed with this source code.
|
|
|
9 |
*/
|
|
|
10 |
namespace PharIo\Manifest;
|
|
|
11 |
|
|
|
12 |
use PharIo\Version\Version;
|
|
|
13 |
use PharIo\Version\VersionConstraint;
|
|
|
14 |
|
|
|
15 |
class Extension extends Type {
|
|
|
16 |
/** @var ApplicationName */
|
|
|
17 |
private $application;
|
|
|
18 |
|
|
|
19 |
/** @var VersionConstraint */
|
|
|
20 |
private $versionConstraint;
|
|
|
21 |
|
|
|
22 |
public function __construct(ApplicationName $application, VersionConstraint $versionConstraint) {
|
|
|
23 |
$this->application = $application;
|
|
|
24 |
$this->versionConstraint = $versionConstraint;
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
public function getApplicationName(): ApplicationName {
|
|
|
28 |
return $this->application;
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
public function getVersionConstraint(): VersionConstraint {
|
|
|
32 |
return $this->versionConstraint;
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
public function isExtension(): bool {
|
|
|
36 |
return true;
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
public function isExtensionFor(ApplicationName $name): bool {
|
|
|
40 |
return $this->application->isEqual($name);
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
public function isCompatibleWith(ApplicationName $name, Version $version): bool {
|
|
|
44 |
return $this->isExtensionFor($name) && $this->versionConstraint->complies($version);
|
|
|
45 |
}
|
|
|
46 |
}
|