Extension.php 1.4 KB

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