Completed
Push — master ( fd62a8...5cbc9e )
by Filipe
04:02
created

RelationsMap   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

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 0
cts 5
cp 0
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\Descriptor;
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\Mapper\RelationInterface;
16
17
/**
18
 * RelationsMap
19
 *
20
 * @package Slick\Orm\Descriptor
21
 * @author  Filipe Silva <[email protected]>
22
 */
23
class RelationsMap extends AbstractMap implements MapInterface
24
{
25
26
    /**
27
     * Puts a new relation in the map.
28
     *
29
     * @param mixed $key
30
     * @param mixed $value
31
     *
32
     * @return RelationsMap
33
     */
34
    public function set($key, $value)
35
    {
36
        if (! $value instanceof RelationInterface) {
37
            throw new InvalidArgumentException(
38
                "Only RelationInterface objects can be putted in a ".
39
                "RelationsMap."
40
            );
41
        }
42
        return parent::set($key, $value);
43
    }
44
}