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

RepositoryMap   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 22
ccs 6
cts 6
cp 1
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\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
}