forked from LiveCarta/PayPal-PHP-SDK
Enabled Payment Experience
- Updated Api to enabled Payment Experience - Updated Tests and Samples - Added Json Validator - Ability for PPModel to return array of self objects
This commit is contained in:
28
lib/PayPal/Validation/JsonValidator.php
Normal file
28
lib/PayPal/Validation/JsonValidator.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Validation;
|
||||
|
||||
/**
|
||||
* Class JsonValidator
|
||||
*
|
||||
* @package PayPal\Validation
|
||||
*/
|
||||
class JsonValidator
|
||||
{
|
||||
|
||||
/**
|
||||
* Helper method for validating if string provided is a valid json.
|
||||
*
|
||||
* @param string $string String representation of Json object
|
||||
* @return bool
|
||||
*/
|
||||
public static function validate($string)
|
||||
{
|
||||
json_decode($string);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
//Throw an Exception for string or array
|
||||
throw new \InvalidArgumentException("Invalid JSON String");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user