Embedded::noPrefix()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
3
namespace LaravelDoctrine\Fluent\Builders;
4
5
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
6
use Doctrine\ORM\Mapping\NamingStrategy;
7
use LaravelDoctrine\Fluent\Buildable;
8
9
class Embedded extends AbstractBuilder implements Buildable
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $embeddable;
15
16
    /**
17
     * @var string
18
     */
19
    protected $relation;
20
21
    /**
22
     * @var string|null
23
     */
24
    protected $columnPrefix = null;
25
26
    /**
27
     * @param ClassMetadataBuilder $builder
28
     * @param NamingStrategy       $namingStrategy
29
     * @param string               $relation
30
     * @param string               $embeddable
31
     */
32 6
    public function __construct(ClassMetadataBuilder $builder, NamingStrategy $namingStrategy, $relation, $embeddable)
33
    {
34 6
        parent::__construct($builder, $namingStrategy);
35
36 6
        $this->embeddable = $embeddable;
37 6
        $this->relation   = $relation;
38 6
    }
39
40
    /**
41
     * @param string|null $prefix
42
     *
43
     * @return Embedded
44
     */
45 1
    public function prefix($prefix)
46
    {
47 1
        $this->columnPrefix = $prefix;
48
49 1
        return $this;
50
    }
51
52
    /**
53
     * @return Embedded
54
     */
55 1
    public function noPrefix()
56
    {
57 1
        $this->columnPrefix = false;
58
59 1
        return $this;
60
    }
61
62
    /**
63
     * Execute the build process
64
     */
65 5
    public function build()
66
    {
67 5
        $this->builder->addEmbedded(
68 5
            $this->relation,
69 5
            $this->embeddable,
70 5
            $this->columnPrefix
71 5
        );
72 5
    }
73
}
74