Permalink
Browse files

Alias feature

  • Loading branch information...
1 parent 22e0244 commit 041c3a72b20a4020d5409323be1a9898df49d749 @ftaiolivista committed Oct 12, 2011
Showing with 17 additions and 0 deletions.
  1. +17 −0 lib/Pimple.php
View
@@ -145,4 +145,21 @@ function raw($id)
return $this->values[$id];
}
+
+ /**
+ * Sometimes is usefull to have properties/objects aliases
+ *
+ * @param string $src The unique identifier for existing the parameter or object
+ *
+ * @param string $dst The unique new alias
+ *
+ * @throws InvalidArgumentException if the identifier is not defined
+ */
+ function alias($src, $dst){
+ if (!isset($this->values[$src])) {
+ throw new InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
+ }
+ $this->values[$dst] &= $this->values[$src];
+ }
+
}

0 comments on commit 041c3a7

Please sign in to comment.