Completed
Push — master ( 00ac10...57b531 )
by Filipe
03:06
created

RepositoryMap::set()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 6
nc 2
nop 2
crap 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\Repository;
11
12
use Slick\Common\Utils\Collection\AbstractMap;
13
use Slick\Common\Utils\Collection\MapInterface;
14
use Slick\Orm\Exception\InvalidArgumentException;
15
use Slick\Orm\RepositoryInterface;
16
17
/**
18
 * Repository Map
19
 *
20
 * @package Slick\Orm\Repository
21
 * @author Filipe Silva
22
 */
23
class RepositoryMap extends AbstractMap implements MapInterface
24
{
25
26
    /**
27
     * Puts a new repository in the map.
28
     *
29
     * @param mixed $key
30
     * @param mixed $value
31
     *
32
     * @return $this|self|MapInterface
33
     */
34 4
    public function set($key, $value)
35
    {
36 4
        if (! $value instanceof RepositoryInterface) {
37 2
            throw new InvalidArgumentException(
38
                "Only RepositoryInterface object can be putted in a ".
39 1
                "RepositoryMap."
40 1
            );
41
        }
42 4
        return parent::set($key, $value);
43
    }
44
}