Embedded   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
c 3
b 0
f 0
lcom 1
cbo 2
dl 0
loc 65
ccs 18
cts 18
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A prefix() 0 6 1
A noPrefix() 0 6 1
A build() 0 8 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