AbstractInvalidTypeException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 24
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 3
1
<?php
2
namespace GenericCollections\Exceptions;
3
4
/**
5
 * AbstractInvalidTypeException
6
 *
7
 * This abstract class provides a template for the extended classes:
8
 * - InvalidKeyTypeException
9
 * - InvalidElementTypeException
10
 * - InvalidValueTypeException
11
 * - InvalidDefaultValueTypeException
12
 *
13
 * @package GenericCollections\Exceptions
14
 */
15
abstract class AbstractInvalidTypeException extends GenericCollectionsException
16
{
17
    /**
18
     * This property define the name of the property
19
     * @var string
20
     */
21
    protected $propertyName = '';
22
23
    /**
24
     * Invalid Property Type
25
     *
26
     * @param string            $container      Description of the container, like 'Map'
27
     * @param string            $expectedType   Description of the expected type
28
     * @param mixed             $source         Object name or object that throws the exception
29
     * @param int               $code           Exception code
30
     * @param \Exception|null   $previous       Previous exception
31
     */
32 11
    public function __construct($container, $expectedType, $source, $code = 0, \Exception $previous = null)
33
    {
34 11
        $source = (is_object($source)) ? get_class($source) : (is_string($source) ? $source : '(unknown)');
35 11
        $message = "Invalid {$this->propertyName} type; the $container $source was expecting a $expectedType type";
36 11
        parent::__construct($message, $code, $previous);
37 11
    }
38
}
39