Link.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Package;
  12. use Composer\Package\LinkConstraint\LinkConstraintInterface;
  13. /**
  14. * Represents a link between two packages, represented by their names
  15. *
  16. * @author Nils Adermann <naderman@naderman.de>
  17. */
  18. class Link
  19. {
  20. protected $source;
  21. protected $target;
  22. protected $constraint;
  23. protected $description;
  24. /**
  25. * Creates a new package link.
  26. *
  27. * @param string $source
  28. * @param string $target
  29. * @param LinkConstraintInterface $constraint Constraint applying to the target of this link
  30. * @param string $description Used to create a descriptive string representation
  31. */
  32. public function __construct($source, $target, LinkConstraintInterface $constraint, $description = 'relates to')
  33. {
  34. $this->source = $source;
  35. $this->target = $target;
  36. $this->constraint = $constraint;
  37. $this->description = $description;
  38. }
  39. public function getSource()
  40. {
  41. return $this->source;
  42. }
  43. public function getTarget()
  44. {
  45. return $this->target;
  46. }
  47. public function getConstraint()
  48. {
  49. return $this->constraint;
  50. }
  51. public function __toString()
  52. {
  53. return $this->source.' '.$this->description.' '.$this->target.' ('.$this->constraint.')';
  54. }
  55. }