Completed
Push — extensions-support ( 1dda5d...e16b25 )
by Guido
03:56 queued 49s
created

OneToOne::__call()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
ccs 4
cts 4
cp 1
cc 2
eloc 4
nc 2
nop 2
crap 2
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
     * @return AssociationBuilder
27
     */
28 29
    protected function createAssociation(ClassMetadataBuilder $builder, $relation, $entity)
29
    {
30 29
        return $this->builder->createOneToOne(
31 29
            $relation,
32
            $entity
33 29
        );
34
    }
35
36
    /**
37
     * @param string $method
38
     * @param array  $args
39
     *
40
     * @throws \BadMethodCallException
41
     * @return $this
42
     */
43 12
    public function __call($method, $args)
44
    {
45 12
        if ($this->hasMacro($method)) {
46 4
            return $this->queueMacro($method, $args);
47
        }
48
49 8
        return parent::__call($method, $args);
50
    }
51
}
52