1
0
Fork 0

Add prettyConstraint on Links

pull/110/merge
Jordi Boggiano 2011-11-20 18:56:00 +01:00
parent a54ec23e38
commit 52a9014f1a
2 changed files with 12 additions and 4 deletions

View File

@ -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.')';

View File

@ -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;