]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - vendor/wikimedia/assert/src/ParameterTypeException.php
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / vendor / wikimedia / assert / src / ParameterTypeException.php
1 <?php
2
3 namespace 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  * @license MIT
10  * @author Daniel Kinzler
11  * @copyright Wikimedia Deutschland e.V.
12  */
13 class ParameterTypeException extends ParameterAssertionException {
14
15         /**
16          * @var string
17          */
18         private $parameterType;
19
20         /**
21          * @param string $parameterName
22          * @param string $parameterType
23          *
24          * @throws ParameterTypeException
25          */
26         public function __construct( $parameterName, $parameterType ) {
27                 if ( !is_string( $parameterType ) ) {
28                         throw new ParameterTypeException( 'parameterType', 'string' );
29                 }
30
31                 parent::__construct( $parameterName, "must be a $parameterType" );
32
33                 $this->parameterType = $parameterType;
34         }
35
36         /**
37          * @return string
38          */
39         public function getParameterType() {
40                 return $this->parameterType;
41         }
42
43 }