Skip to content

Commit

Permalink
Validation for MonetaryValue in Discount entity
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandoorn committed Jun 20, 2015
1 parent 6d1b2c2 commit d77755e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Ups/Entity/Discount.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ public function getMonetaryValue() {
* @param $var
*/
public function setMonetaryValue($var) {
$this->MonetaryValue = $var;
$this->monetaryValue = $var;
$this->monetaryValue = round($var, 2); // Max 2 decimals places

if(strlen((string) $this->monetaryValue) > 15) {
throw new \Exception('Value too long');
}

return $this;
}

}

0 comments on commit d77755e

Please sign in to comment.