Completed
Push — master ( 8eb315...5aaba6 )
by Changwan
04:29
created

RelatedToMany   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
ccs 0
cts 6
cp 0
rs 10
wmc 1
lcom 1
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getRelation() 0 6 1
1
<?php
2
namespace Wandu\Database\Annotations;
3
4
use Doctrine\Common\Annotations\Annotation\Required;
5
use Doctrine\Common\Annotations\Annotation\Target;
6
use Wandu\Database\DatabaseManager;
7
use Wandu\Database\Query\SelectQuery;
8
9
/**
10
 * @Annotation
11
 * @Target({"PROPERTY"})
12
 */
13
class RelatedToMany implements RelationInterface
14
{
15
    /**
16
     * @Required
17
     * @var string
18
     */
19
    public $related;
20
21
    /**
22
     * @var string
23
     */
24
    public $key = 'id';
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function getRelation(DatabaseManager $manager, $columnValue)
30
    {
31
        return $manager->repository($this->related)->all(function (SelectQuery $query) use ($columnValue) {
32
            return $query->where($this->key, $columnValue);
33
        });
34
    }
35
}
36