InvalidItemException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 0
cts 8
cp 0
rs 9.4285
cc 1
eloc 7
nc 1
nop 2
crap 2
1
<?php
2
namespace Nayjest\Collection\Exceptions;
3
4
use InvalidArgumentException;
5
6
/**
7
 * Class for exceptions about invalid type of items used with collection.
8
 */
9
class InvalidItemException extends InvalidArgumentException
10
{
11
    /**
12
     * Constructor.
13
     *
14
     * @param string $item
15
     * @param string[] $expectedTypes
16
     */
17
    public function __construct($item, array $expectedTypes)
18
    {
19
        $actualClass = get_class($item);
20
        parent::__construct(
21
            "Trying to add $actualClass"
22
            . 'to collection that supports only following types:'
23
            . implode(', ', $expectedTypes)
24
            . '.'
25
        );
26
    }
27
}
28