Completed
Pull Request — 1.1 (#35)
by Hidde
04:20
created

Table   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 5
c 4
b 0
f 0
lcom 1
cbo 3
dl 0
loc 53
ccs 16
cts 16
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A setName() 0 6 1
A schema() 0 6 1
A setOptions() 0 6 1
1
<?php
2
3
namespace LaravelDoctrine\Fluent\Builders;
4
5
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
6
7
class Table extends AbstractBuilder
8
{
9
    /**
10
     * @param ClassMetadataBuilder $builder
11
     * @param string|callable|null $name
12
     */
13 9
    public function __construct(ClassMetadataBuilder $builder, $name = null)
14
    {
15 9
        parent::__construct($builder);
16
17 9
        if (is_callable($name)) {
18 2
            $name($this);
19 2
        } else {
20 9
            $this->setName($name);
21
        }
22 9
    }
23
24
    /**
25
     * @param string $name
26
     *
27
     * @return $this
28
     */
29 9
    public function setName($name)
30
    {
31 9
        $this->builder->setTable($name);
32
33 9
        return $this;
34
    }
35
36
    /**
37
     * @param string $schema
38
     *
39
     * @return $this
40
     */
41 1
    public function schema($schema)
42
    {
43 1
        $this->builder->getClassMetadata()->setPrimaryTable(['schema' => $schema]);
44
45 1
        return $this;
46
    }
47
48
    /**
49
     * @param array $options
50
     *
51
     * @return $this
52
     */
53 2
    public function setOptions(array $options = [])
54
    {
55 2
        $this->builder->getClassMetadata()->setPrimaryTable(['options' => $options]);
56
57 2
        return $this;
58
    }
59
}
60