Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
ParameterElementTypeException
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 getElementType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Wikimedia\Assert;
4
5/**
6 * Exception indicating that a parameter element type assertion failed.
7 * This generally means a disagreement between the caller and the implementation of a function.
8 *
9 * @since 0.1.0
10 *
11 * @license MIT
12 * @author Daniel Kinzler
13 * @copyright Wikimedia Deutschland e.V.
14 */
15class ParameterElementTypeException extends ParameterAssertionException {
16
17    /**
18     * @var string
19     */
20    private $elementType;
21
22    /**
23     * @param string $parameterName
24     * @param string $elementType
25     *
26     * @throws ParameterTypeException
27     */
28    public function __construct( $parameterName, $elementType ) {
29        if ( !is_string( $elementType ) ) {
30            throw new ParameterTypeException( 'elementType', 'string' );
31        }
32
33        parent::__construct( $parameterName, "all elements must be $elementType" );
34
35        $this->elementType = $elementType;
36    }
37
38    /**
39     * @return string
40     */
41    public function getElementType(): string {
42        return $this->elementType;
43    }
44
45}