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

Table::schema()   A

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 1
crap 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 10
    public function __construct(ClassMetadataBuilder $builder, $name = null)
14
    {
15 10
        parent::__construct($builder);
16
17 10
        if (is_callable($name)) {
18 2
            $name($this);
19 2
        } else {
20 10
            $this->setName($name);
21
        }
22 10
    }
23
24
    /**
25
     * @param string $name
26
     *
27
     * @return $this
28
     */
29 10
    public function setName($name)
30
    {
31 10
        $this->builder->setTable($name);
32
33 10
        return $this;
34
    }
35
36
    /**
37
     * @param string $schema
38
     *
39
     * @return $this
40
     */
41 2
    public function schema($schema)
42
    {
43 2
        $this->builder->getClassMetadata()->setPrimaryTable(['schema' => $schema]);
44
45 2
        return $this;
46
    }
47
48
    /**
49
     * @param array $options
50
     *
51
     * @return $this
52
     */
53 3
    public function setOptions(array $options = [])
54
    {
55 3
        $this->builder->getClassMetadata()->setPrimaryTable(['options' => $options]);
56
57 3
        return $this;
58
    }
59
}
60