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

EmittersMap::set()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
ccs 3
cts 6
cp 0.5
rs 9.4285
cc 2
eloc 6
nc 2
nop 2
crap 2.5
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
}