コード例 #1
0
 /**
  * @param NumberValue\MultipleOfConstraint $constraint
  *
  * @return string
  */
 public function visitMultipleOfConstraint(NumberValue\MultipleOfConstraint $constraint)
 {
     return sprintf('The number must be a multiple of %s.', var_export($constraint->quantity(), true));
 }
コード例 #2
0
 /**
  * @param NumberValue\MultipleOfConstraint $constraint
  *
  * @return Result\ValidationResult
  */
 public function visitMultipleOfConstraint(NumberValue\MultipleOfConstraint $constraint)
 {
     $value = $this->currentValue();
     if (!$value instanceof Value\NumberValueInterface) {
         return $this->createResult();
     }
     if ($value instanceof Value\FloatingPointValue || is_float($constraint->quantity())) {
         if (0 == fmod($value->value(), $constraint->quantity())) {
             return $this->createResult();
         }
     } else {
         if (0 === $value->value() % $constraint->quantity()) {
             return $this->createResult();
         }
     }
     return $this->createSingleIssueResult($constraint);
 }