Completed
Push — master ( 57b531...5d4578 )
by Filipe
02:14
created

EmittersMap   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 22
ccs 3
cts 6
cp 0.5
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A set() 0 10 2
1
<?php
2
3
/**
4
 * This file is part of slick/orm package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Orm\Event;
11
12
use League\Event\EmitterInterface;
13
use Slick\Common\Utils\Collection\AbstractMap;
14
use Slick\Common\Utils\Collection\MapInterface;
15
use Slick\Orm\Exception\InvalidArgumentException;
16
17
/**
18
 * Emitters Map
19
 *
20
 * @package Slick\Orm\Event
21
 * @author  Filipe Silva <[email protected]>
22
 */
23
class EmittersMap extends AbstractMap implements MapInterface
24
{
25
26
    /**
27
     * Puts a new emitter in the map.
28
     *
29
     * @param mixed $key
30
     * @param EmitterInterface $value
31
     *
32
     * @return $this|self|MapInterface
33
     */
34 2
    public function set($key, $value)
35
    {
36 2
        if (! $value instanceof EmitterInterface) {
37
            throw new InvalidArgumentException(
38
                "Only EmitterInterface object can be putted in a ".
39
                "EmittersMap."
40
            );
41
        }
42 2
        return parent::set($key, $value);
43
    }
44
}