InvalidItemException   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
c 2
b 0
f 0
lcom 0
cbo 0
dl 0
loc 19
ccs 0
cts 8
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
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