PayPal\Validation\NumericValidator::validate PHP Method

validate() public static method

Helper method for validating an argument if it is numeric
public static validate ( mixed $argument, string | null $argumentName = null ) : boolean
$argument mixed
$argumentName string | null
return boolean
    public static function validate($argument, $argumentName = null)
    {
        if (trim($argument) != null && !is_numeric($argument)) {
            throw new \InvalidArgumentException("{$argumentName} is not a valid numeric value");
        }
        return true;
    }

Usage Example

Beispiel #1
0
 /**
  * Total amount charged as part of this payment.
  *
  *
  * @param string|double $total
  *
  * @return $this
  */
 public function setTotal($total)
 {
     NumericValidator::validate($total, "Total");
     $total = FormatConverter::formatToPrice($total, $this->getCurrency());
     $this->total = $total;
     return $this;
 }
All Usage Examples Of PayPal\Validation\NumericValidator::validate
NumericValidator