Passed
Push — master ( 905821...42a403 )
by Mr
07:23
created

TransportMap   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
dl 0
loc 17
rs 10
c 2
b 0
f 0
ccs 8
cts 8
cp 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 3
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the daikon-cqrs/message-bus project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Daikon\MessageBus\Channel\Subscription\Transport;
10
11
use Daikon\DataStructure\TypedMapInterface;
12
use Daikon\DataStructure\TypedMapTrait;
0 ignored issues
show
Bug introduced by
The type Daikon\DataStructure\TypedMapTrait was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use InvalidArgumentException;
14
15
final class TransportMap implements TypedMapInterface
16
{
17
    use TypedMapTrait;
18
19 3
    public function __construct(iterable $transports = [])
20
    {
21 3
        $mappedTransports = [];
22
        /** @var TransportInterface $transport */
23 3
        foreach ($transports as $transport) {
24 2
            $transportKey = $transport->getKey();
25 2
            if (isset($mappedTransports[$transportKey])) {
26 1
                throw new InvalidArgumentException("Transport key '$transportKey' is already defined.");
27
            }
28 2
            $mappedTransports[$transportKey] = $transport;
29
        }
30
31 2
        $this->init($mappedTransports, [TransportInterface::class]);
32 2
    }
33
}
34