3 namespace Wikimedia\Assert;
5 use InvalidArgumentException;
8 * Exception indicating that an parameter assertion failed.
9 * This generally means a disagreement between the caller and the implementation of a function.
12 * @author Daniel Kinzler
13 * @copyright Wikimedia Deutschland e.V.
15 class ParameterAssertionException extends InvalidArgumentException implements AssertionException {
20 private $parameterName;
23 * @param string $parameterName
24 * @param string $description
26 * @throws ParameterTypeException
28 public function __construct( $parameterName, $description ) {
29 if ( !is_string( $parameterName ) ) {
30 throw new ParameterTypeException( 'parameterName', 'string' );
33 if ( !is_string( $description ) ) {
34 throw new ParameterTypeException( 'description', 'string' );
37 parent::__construct( "Bad value for parameter $parameterName: $description" );
39 $this->parameterName = $parameterName;
45 public function getParameterName() {
46 return $this->parameterName;