InvalidTypeException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 15
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
1
<?php
2
3
namespace BestServedCold\PhalueObjects\Exception;
4
5
use BestServedCold\PhalueObjects\Format\Csv;
6
use BestServedCold\PhalueObjects\Mathematical\Integer;
7
8
/**
9
 * Class InvalidTypeException
10
 *
11
 * @package   BestServedCold\PhalueObjects\Exception
12
 * @author    Adam Lewis <[email protected]>
13
 * @copyright Copyright (c) 2015 Best Served Cold Media Limited
14
 * @license   http://http://opensource.org/licenses/GPL-3.0 GPL License
15
 * @link      http://bestservedcold.com
16
 * @since     0.0.1-alpha
17
 * @version   0.0.2-alpha
18
 */
19
class InvalidTypeException extends \InvalidArgumentException
20
{
21
    /**
22
     * @param string $value
23
     * @param array  $allowedTypes
24
     */
25 12
    public function __construct($value, array $allowedTypes)
26
    {
27 12
        $value = is_array($value) ?: var_export($value, true);
28 12
        $this->message =
29 12
            '[PhalueObjects] Argument ['.$value.'] of type ['.gettype($value).
30 12
            '] is not a valid type.'.' The allowed type(s) are ['.
31 12
            Csv::fromArray($allowedTypes)->getValue().']';
32 12
    }
33
}
34