コード例 #1
0
 /**
  * Returns the value of type
  *
  * @param boolean $filter If false, the given types will be filtered out
  *
  * @return Money
  */
 public function getValueOfType($price, Type $type, $filter = true)
 {
     if ($price instanceof Money === false) {
         throw new InvalidArgumentException('The given value is not a valid Money object.');
     }
     $total = new Money(0, $price->getCurrency());
     foreach ($this->data as $option) {
         $value = $option->getValue($price);
         $price = $price->add($value);
         if ($type->validate($option) === (bool) $filter) {
             $total = $total->add($value);
         }
     }
     return $total;
 }
コード例 #2
0
ファイル: Collection.php プロジェクト: indigophp/container
 /**
  * Validates one value
  *
  * @param mixed $value
  */
 public function validateOne($value)
 {
     if ($this->type->validate($value) === false) {
         throw new InvalidArgumentException($this->type->getMessage());
     }
 }