Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
50.00% covered (danger)
50.00%
1 / 2
CRAP
75.00% covered (warning)
75.00%
6 / 8
Wikimedia\Assert\ParameterAssertionException
0.00% covered (danger)
0.00%
0 / 1
50.00% covered (danger)
50.00%
1 / 2
4.25
75.00% covered (warning)
75.00%
6 / 8
 __construct
0.00% covered (danger)
0.00%
0 / 1
3.21
71.43% covered (warning)
71.43%
5 / 7
 getParameterName
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
<?php
namespace Wikimedia\Assert;
use InvalidArgumentException;
/**
 * Exception indicating that an parameter assertion failed.
 * This generally means a disagreement between the caller and the implementation of a function.
 *
 * @since 0.1.0
 *
 * @license MIT
 * @author Daniel Kinzler
 * @copyright Wikimedia Deutschland e.V.
 */
class ParameterAssertionException extends InvalidArgumentException implements AssertionException {
    /**
     * @var string
     */
    private $parameterName;
    /**
     * @param string $parameterName
     * @param string $description
     *
     * @throws ParameterTypeException
     */
    public function __construct( $parameterName, $description ) {
        if ( !is_string( $parameterName ) ) {
            throw new ParameterTypeException( 'parameterName', 'string' );
        }
        if ( !is_string( $description ) ) {
            throw new ParameterTypeException( 'description', 'string' );
        }
        parent::__construct( "Bad value for parameter $parameterName$description" );
        $this->parameterName = $parameterName;
    }
    /**
     * @return string
     */
    public function getParameterName() {
        return $this->parameterName;
    }
}