recreate project

This commit is contained in:
root
2026-02-10 22:11:06 -05:00
commit 663c0cdbda
10149 changed files with 1379710 additions and 0 deletions
@@ -0,0 +1,32 @@
<?php
namespace PayPal\Validation;
/**
* Class ArgumentValidator
*
* @package PayPal\Validation
*/
class ArgumentValidator
{
/**
* Helper method for validating an argument that will be used by this API in any requests.
*
* @param $argument mixed The object to be validated
* @param $argumentName string|null The name of the argument.
* This will be placed in the exception message for easy reference
* @return bool
*/
public static function validate($argument, $argumentName = null)
{
if ($argument === null) {
// Error if Object Null
throw new \InvalidArgumentException("$argumentName cannot be null");
} else if (gettype($argument) == 'string' && trim($argument) == ''){
// Error if String Empty
throw new \InvalidArgumentException("$argumentName string cannot be empty");
}
return true;
}
}
@@ -0,0 +1,35 @@
<?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
* @param bool $silent Flag to not throw \InvalidArgumentException
* @return bool
*/
public static function validate($string, $silent = false)
{
@json_decode($string);
if (json_last_error() != JSON_ERROR_NONE) {
if ($string === '' || $string === null) {
return true;
}
if ($silent == false) {
//Throw an Exception for string or array
throw new \InvalidArgumentException("Invalid JSON String");
}
return false;
}
return true;
}
}
@@ -0,0 +1,28 @@
<?php
namespace PayPal\Validation;
/**
* Class NumericValidator
*
* @package PayPal\Validation
*/
class NumericValidator
{
/**
* Helper method for validating an argument if it is numeric
*
* @param mixed $argument
* @param string|null $argumentName
* @return bool
*/
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;
}
}
@@ -0,0 +1,26 @@
<?php
namespace PayPal\Validation;
/**
* Class UrlValidator
*
* @package PayPal\Validation
*/
class UrlValidator
{
/**
* Helper method for validating URLs that will be used by this API in any requests.
*
* @param $url
* @param string|null $urlName
* @throws \InvalidArgumentException
*/
public static function validate($url, $urlName = null)
{
if (filter_var($url, FILTER_VALIDATE_URL) === false) {
throw new \InvalidArgumentException("$urlName is not a fully qualified URL");
}
}
}