Add prettyConstraint on Links
parent
a54ec23e38
commit
52a9014f1a
|
@ -34,12 +34,13 @@ class Link
|
|||
* @param LinkConstraintInterface $constraint Constraint applying to the target of this link
|
||||
* @param string $description Used to create a descriptive string representation
|
||||
*/
|
||||
public function __construct($source, $target, LinkConstraintInterface $constraint = null, $description = 'relates to')
|
||||
public function __construct($source, $target, LinkConstraintInterface $constraint = null, $description = 'relates to', $prettyConstraint = null)
|
||||
{
|
||||
$this->source = strtolower($source);
|
||||
$this->target = strtolower($target);
|
||||
$this->constraint = $constraint;
|
||||
$this->description = $description;
|
||||
$this->prettyConstraint = $prettyConstraint;
|
||||
}
|
||||
|
||||
public function getSource()
|
||||
|
@ -57,6 +58,15 @@ class Link
|
|||
return $this->constraint;
|
||||
}
|
||||
|
||||
public function getPrettyConstraint()
|
||||
{
|
||||
if (null === $this->prettyConstraint) {
|
||||
throw new \UnexpectedValueException(sprintf('Link %s has been misconfigured and had no prettyConstraint given.', $this));
|
||||
}
|
||||
|
||||
return $this->prettyConstraint;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->source.' '.$this->description.' '.$this->target.' ('.$this->constraint.')';
|
||||
|
|
|
@ -143,10 +143,8 @@ class ArrayLoader
|
|||
{
|
||||
$links = array();
|
||||
foreach ($linksSpecs as $packageName => $constraint) {
|
||||
$name = strtolower($packageName);
|
||||
|
||||
$constraint = $this->versionParser->parseConstraints($constraint);
|
||||
$links[] = new Package\Link($srcPackageName, $packageName, $constraint, $description);
|
||||
$links[] = new Package\Link($srcPackageName, $packageName, $constraint, $description, $constraint);
|
||||
}
|
||||
|
||||
return $links;
|
||||
|
|
Loading…
Reference in New Issue