1 <?php
2
3 namespace PayPal\Validation;
4
5 /**
6 * Class NumericValidator
7 *
8 * @package PayPal\Validation
9 */
10 class NumericValidator
11 {
12
13 /**
14 * Helper method for validating an argument if it is numeric
15 *
16 * @param mixed $argument
17 * @param string|null $argumentName
18 * @return bool
19 */
20 public static function validate($argument, $argumentName = null)
21 {
22 if (trim($argument) != null && !is_numeric($argument)) {
23 throw new \InvalidArgumentException("$argumentName is not a valid numeric value");
24 }
25 return true;
26 }
27 }
28