installed plugin Easy Digital Downloads
version 3.1.0.3
This commit is contained in:
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Attribute_Not_Found exception class
|
||||
*
|
||||
* @package EDD
|
||||
* @subpackage Classes/Utilities
|
||||
* @copyright Copyright (c) 2018, Easy Digital Downloads, LLC
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 3.0
|
||||
*/
|
||||
namespace EDD\Utils\Exceptions;
|
||||
|
||||
/**
|
||||
* Implements an Attribute_Not_Found exception thrown when a given
|
||||
* attribute is not found.
|
||||
*
|
||||
* @since 3.0
|
||||
*
|
||||
* @see \OutOfBoundsException
|
||||
* @see \EDD_Exception
|
||||
*/
|
||||
class Attribute_Not_Found extends \OutOfBoundsException implements \EDD_Exception {
|
||||
|
||||
/**
|
||||
* Retrieves an informed Attribute_Not_Found instance via late-static binding.
|
||||
*
|
||||
* @since 3.0
|
||||
*
|
||||
* @param string $attribute_name Attribute resulting in the exception.
|
||||
* @param string $collection Collection the attribute belongs to.
|
||||
* @param int $code Optional. Exception code. Default null.
|
||||
* @param \Exception $previous Optional. Previous exception (used for chaining).
|
||||
* Default null.
|
||||
* @return \EDD\Utils\Exceptions\Attribute_Not_Found Exception instance.
|
||||
*/
|
||||
public static function from_attr( $attribute_name, $collection, $code = null, $previous = null ) {
|
||||
$message = sprintf( 'The \'%1$s\' attribute does not exist for \'%2$s\'.',
|
||||
$attribute_name,
|
||||
$collection
|
||||
);
|
||||
|
||||
return new static( $message, $code, $previous);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* Invalid_Argument exception class
|
||||
*
|
||||
* @package EDD
|
||||
* @subpackage Classes/Utilities
|
||||
* @copyright Copyright (c) 2018, Easy Digital Downloads, LLC
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 3.0
|
||||
*/
|
||||
namespace EDD\Utils\Exceptions;
|
||||
|
||||
/**
|
||||
* Implements an Invalid_Argument exception thrown when a given
|
||||
* argument or parameter is invalid.
|
||||
*
|
||||
* @since 3.0
|
||||
*
|
||||
* @see \InvalidArgumentException
|
||||
* @see \EDD_Exception
|
||||
*/
|
||||
class Invalid_Argument extends \InvalidArgumentException implements \EDD_Exception {
|
||||
|
||||
/**
|
||||
* Type of value.
|
||||
*
|
||||
* @since 3.0
|
||||
* @var string
|
||||
*/
|
||||
public static $type = 'argument';
|
||||
|
||||
/**
|
||||
* Exception message.
|
||||
*
|
||||
* @since 3.0
|
||||
* @var string|null
|
||||
*/
|
||||
public static $error_message;
|
||||
|
||||
/**
|
||||
* Retrieves an informed Invalid_Argument instance via late-static binding.
|
||||
*
|
||||
* @since 3.0
|
||||
*
|
||||
* @param string $argument_name Argument or parameter resulting in the exception.
|
||||
* @param string $method Function or method name the argument or parameter was passed to.
|
||||
* @param string $context Further context under which to build the exception message. To be
|
||||
* used by sub-classes when overriding build_message(). Default null.
|
||||
* @param int $code Optional. Exception code. Default null.
|
||||
* @param \Exception $previous Optional. Previous exception (used for chaining).
|
||||
* Default null.
|
||||
* @return \EDD\Utils\Exceptions\Invalid_Argument Exception instance.
|
||||
*/
|
||||
public static function from( $argument_name, $method, $context = null ) {
|
||||
static::build_message( $argument_name, $method, $context );
|
||||
|
||||
return new static( static::$error_message );
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the Invalid_Argument exception message.
|
||||
*
|
||||
* Abstracted to allow for completely overriding the exception message in a subclass.
|
||||
*
|
||||
* @since 3.0
|
||||
*
|
||||
* @param string $argument_name Argument or parameter resulting in the exception.
|
||||
* @param string $method Function or method name the argument or parameter was passed to.
|
||||
* @param string $context Further context under which to build the exception message. To be
|
||||
* used by sub-classes when overriding build_message(). Default null.
|
||||
* @return string Informed Invalid_Argument message.
|
||||
*/
|
||||
public static function build_message( $argument_name, $method, $context = null ) {
|
||||
if ( ! isset( static::$error_message ) ) {
|
||||
|
||||
if ( ! isset( self::$type ) ) {
|
||||
self::$type = 'argument';
|
||||
}
|
||||
|
||||
self::$error_message = sprintf( 'The \'%1$s\' %2$s is missing or invalid for \'%3$s\'.',
|
||||
$argument_name,
|
||||
static::$type,
|
||||
$method
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Invalid_Parameter exception class
|
||||
*
|
||||
* @package EDD
|
||||
* @subpackage Classes/Utilities
|
||||
* @copyright Copyright (c) 2018, Easy Digital Downloads, LLC
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 3.0
|
||||
*/
|
||||
namespace EDD\Utils\Exceptions;
|
||||
|
||||
/**
|
||||
* Implements an Invalid_Argument exception thrown when a given
|
||||
* argument or parameter is invalid.
|
||||
*
|
||||
* @since 3.0
|
||||
*
|
||||
* @see \InvalidArgumentException
|
||||
* @see \EDD_Exception
|
||||
*/
|
||||
class Invalid_Parameter extends Invalid_Argument implements \EDD_Exception {
|
||||
|
||||
/**
|
||||
* Type of value.
|
||||
*
|
||||
* @since 3.0
|
||||
* @var string
|
||||
*/
|
||||
public static $type = 'parameter';
|
||||
|
||||
}
|
Reference in New Issue
Block a user