HasMany   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 17
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getForEntity() 0 6 1
1
<?php
2
/**
3
 *
4
 * This file is part of the Aura project for PHP.
5
 *
6
 * @package Aura.Marshal
7
 *
8
 * @license https://opensource.org/licenses/mit-license.php MIT
9
 *
10
 */
11
namespace Aura\Marshal\Relation;
12
13
use Aura\Marshal\Collection\GenericCollection;
14
15
/**
16
 *
17
 * Represents a relationship where a native entity has many foreign entities
18
 * (i.e., a foreign collection); the foreign entities are subordinate to the
19
 * native one.
20
 *
21
 * @package Aura.Marshal
22
 *
23
 */
24
class HasMany extends AbstractRelation implements RelationInterface
25
{
26
    /**
27
     *
28
     * Returns the related foreign collection for a native entity.
29
     *
30
     * @param mixed $entity The native entity.
31
     *
32
     * @return GenericCollection
33
     *
34
     */
35
    public function getForEntity($entity)
36
    {
37
        $native_field = $this->native_field;
38
        return $this->foreign->getCollectionByField(
39
            $this->foreign_field,
40
            $entity->$native_field
41
        );
42
    }
43
}
44