Permalink
Browse files

Adjusted pricing set to implement ArrayAccess interface for convenience

  • Loading branch information...
1 parent 0290d2f commit dc85d2bc30d398c97e8cc7413d403abe57c21dfd @inspiran inspiran committed with iampersistent Mar 5, 2013
@@ -28,8 +28,12 @@ public function __get($name)
public function get($name)
{
- if (array_key_exists($name, $this->pricingElements)) {
- return $this->pricingElements[$name];
+ if ($this->processingState != self::PROCESSING_FINISHED) {
+ throw new \Exception('Accessing unprocessed pricing element ' . $name);
+ }
+
+ if (isset($this->processed[$name])) {
+ return $this->processed[$name];
}
}
@@ -60,4 +64,25 @@ function getTotalValue()
{
// TODO: Implement getTotalValue() method.
}
+
+ public function offsetExists($offset)
+ {
+ return $this->has($offset);
+ }
+
+ public function offsetGet($offset)
+ {
+ return $this->get($offset);
+ }
+
+ public function offsetSet($offset, $value)
+ {
+ return $this->set($offset, $value);
+ }
+
+ public function offsetUnset($offset)
+ {
+
+ }
+
}
@@ -8,7 +8,7 @@
namespace Vespolina\Entity\Pricing;
-interface PricingSetInterface
+interface PricingSetInterface extends \ArrayAccess
{
function getNetValue();
function getTotalValue();

0 comments on commit dc85d2b

Please sign in to comment.