Debian Codegraph @

vendor/wikimedia/assert/src/ParameterElementTypeException.php

raw
1 <?php
2
3 namespace 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 */
15 class 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 }