InvalidTypeException::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 2
crap 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