Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adjusted pricing set to implement ArrayAccess interface for convenience

  • Loading branch information...
commit dc85d2bc30d398c97e8cc7413d403abe57c21dfd 1 parent 0290d2f
@inspiran inspiran authored iampersistent committed
View
29 lib/Vespolina/Entity/Pricing/PricingSet.php
@@ -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)
+ {
+
+ }
+
}
View
2  lib/Vespolina/Entity/Pricing/PricingSetInterface.php
@@ -8,7 +8,7 @@
namespace Vespolina\Entity\Pricing;
-interface PricingSetInterface
+interface PricingSetInterface extends \ArrayAccess
{
function getNetValue();
function getTotalValue();
Please sign in to comment.
Something went wrong with that request. Please try again.