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
ParameterKeyTypeException
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
 getType
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 key type assertion failed.
7 * This generally means a disagreement between the caller and the implementation of a function.
8 *
9 * @since 0.3.0
10 *
11 * @license MIT
12 * @author Daniel Kinzler
13 * @author Thiemo Kreuz
14 * @copyright Wikimedia Deutschland e.V.
15 */
16class ParameterKeyTypeException extends ParameterAssertionException {
17
18    /**
19     * @var string
20     */
21    private $type;
22
23    /**
24     * @param string $parameterName
25     * @param string $type
26     *
27     * @throws ParameterTypeException
28     */
29    public function __construct( $parameterName, $type ) {
30        if ( !is_string( $type ) ) {
31            throw new ParameterTypeException( 'type', 'string' );
32        }
33
34        parent::__construct( $parameterName, "all elements must have $type keys" );
35
36        $this->type = $type;
37    }
38
39    /**
40     * @return string
41     */
42    public function getType(): string {
43        return $this->type;
44    }
45
46}