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
ParameterTypeException
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
 getParameterType
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 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 ParameterTypeException extends ParameterAssertionException {
16
17    /**
18     * @var string
19     */
20    private $parameterType;
21
22    /**
23     * @param string $parameterName
24     * @param string $parameterType
25     *
26     * @throws ParameterTypeException
27     */
28    public function __construct( $parameterName, $parameterType ) {
29        if ( !is_string( $parameterType ) ) {
30            throw new ParameterTypeException( 'parameterType', 'string' );
31        }
32
33        parent::__construct( $parameterName, "must be a $parameterType" );
34
35        $this->parameterType = $parameterType;
36    }
37
38    /**
39     * @return string
40     */
41    public function getParameterType(): string {
42        return $this->parameterType;
43    }
44
45}