Completed
Push — master ( 814e9e...2525ff )
by Filipe
03:26
created

EntityCollection::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
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\Entity;
11
12
use Slick\Common\Utils\Collection\AbstractCollection;
13
use Slick\Common\Utils\CollectionInterface;
14
use Slick\Orm\EntityInterface;
15
16
/**
17
 * Entity Collection
18
 *
19
 * @package Slick\Orm\Entity
20
 * @author  Filipe Silva <[email protected]>
21
 */
22
class EntityCollection extends AbstractCollection implements
23
    CollectionInterface
24
{
25
26
    /**
27
     * Adds an entity to the collection
28
     *
29
     * @param EntityInterface $entity
30
     * @return $this|self|EntityCollection
31
     */
32
    public function add(EntityInterface $entity)
33
    {
34
        $this->data[] = $entity;
35
        return $this;
36
    }
37
38
    /**
39
     * Offset to set
40
     *
41
     * @link http://php.net/manual/en/arrayaccess.offsetset.php
42
     *
43
     * @param mixed $offset The offset to assign the value to.
44
     * @param mixed $value  The value to set.
45
     */
46
    public function offsetSet($offset, $value)
47
    {
48
        $this->add($value);
49
    }
50
}