Completed
Push — extensions-support ( 73dd44...1dda5d )
by Guido
04:41 queued 01:33
created

OneToOne::__call()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 0
cts 0
cp 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
crap 6
1
<?php
2
3
namespace LaravelDoctrine\Fluent\Relations;
4
5
use Doctrine\ORM\Mapping\Builder\AssociationBuilder;
6
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
7
use LaravelDoctrine\Fluent\Builders\Traits\Macroable;
8
use LaravelDoctrine\Fluent\Builders\Traits\QueuesMacros;
9
use LaravelDoctrine\Fluent\Relations\Traits\Ownable;
10
use LaravelDoctrine\Fluent\Relations\Traits\Owning;
11
use LaravelDoctrine\Fluent\Relations\Traits\Primary;
12
13
/**
14
 * @method $this inversedBy($fieldName)
15
 * @method $this mappedBy($fieldName)
16
 */
17
class OneToOne extends AbstractRelation
18
{
19
    use Owning, Ownable, Primary, Macroable, QueuesMacros;
20
21
    /**
22
     * @param ClassMetadataBuilder $builder
23
     * @param string               $relation
24
     * @param string               $entity
25
     *
26 24
     * @return AssociationBuilder
27
     */
28 24
    protected function createAssociation(ClassMetadataBuilder $builder, $relation, $entity)
29 24
    {
30
        return $this->builder->createOneToOne(
31 24
            $relation,
32
            $entity
33
        );
34
    }
35
36
    /**
37
     * @param string $method
38
     * @param array  $args
39
     *
40
     * @throws \BadMethodCallException
41
     * @return $this
42
     */
43
    public function __call($method, $args)
44
    {
45
        if ($this->hasMacro($method)) {
46
            return $this->queueMacro($method, $args);
47
        }
48
49
        return parent::__call($method, $args);
50
    }
51
52
}
53