diff options
Diffstat (limited to 'vendor/wikimedia/assert/src/ParameterTypeException.php')
-rw-r--r-- | vendor/wikimedia/assert/src/ParameterTypeException.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/vendor/wikimedia/assert/src/ParameterTypeException.php b/vendor/wikimedia/assert/src/ParameterTypeException.php new file mode 100644 index 00000000..943f6c08 --- /dev/null +++ b/vendor/wikimedia/assert/src/ParameterTypeException.php @@ -0,0 +1,43 @@ +<?php + +namespace Wikimedia\Assert; + +/** + * Exception indicating that a parameter type assertion failed. + * This generally means a disagreement between the caller and the implementation of a function. + * + * @license MIT + * @author Daniel Kinzler + * @copyright Wikimedia Deutschland e.V. + */ +class ParameterTypeException extends ParameterAssertionException { + + /** + * @var string + */ + private $parameterType; + + /** + * @param string $parameterName + * @param string $parameterType + * + * @throws ParameterTypeException + */ + public function __construct( $parameterName, $parameterType ) { + if ( !is_string( $parameterType ) ) { + throw new ParameterTypeException( 'parameterType', 'string' ); + } + + parent::__construct( $parameterName, "must be a $parameterType" ); + + $this->parameterType = $parameterType; + } + + /** + * @return string + */ + public function getParameterType() { + return $this->parameterType; + } + +} |