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
83.33% covered (warning)
83.33%
5 / 6
Wikimedia\Assert\ParameterElementTypeException
0.00% covered (danger)
0.00%
0 / 1
50.00% covered (danger)
50.00%
1 / 2
3.04
83.33% covered (warning)
83.33%
5 / 6
 __construct
0.00% covered (danger)
0.00%
0 / 1
2.03
80.00% covered (warning)
80.00%
4 / 5
 getElementType
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
<?php
namespace Wikimedia\Assert;
/**
 * Exception indicating that a parameter element type 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 ParameterElementTypeException extends ParameterAssertionException {
    /**
     * @var string
     */
    private $elementType;
    /**
     * @param string $parameterName
     * @param string $elementType
     *
     * @throws ParameterTypeException
     */
    public function __construct( $parameterName, $elementType ) {
        if ( !is_string( $elementType ) ) {
            throw new ParameterTypeException( 'elementType', 'string' );
        }
        parent::__construct( $parameterName, "all elements must be $elementType" );
        $this->elementType = $elementType;
    }
    /**
     * @return string
     */
    public function getElementType() {
        return $this->elementType;
    }
}