Completed
Push — dev ( 6293b4...41c0d5 )
by James Ekow Abaka
03:00
created

Index::addKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace yentu\database;
3
4
5
class Index extends BasicKey
6
{
7
    protected $unique = false;
8
9
    public function unique($unique = true)
10
    {
11
        $this->unique = $unique;
12
        return $this;
13
    }
14
15 6
    protected function doesKeyExist($constraint)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
16
    {
17 6
        return $this->getDriver()->doesIndexExist($constraint);
18
    }
19
20 6
    protected function addKey($constraint)
21
    {
22 6
        $this->getDriver()->addIndex($constraint);
23 6
    }
24
25
    protected function dropKey($constraint)
26
    {
27
        $this->getDriver()->dropIndex($constraint);
28
    }
29
30 6
    protected function getNamePostfix()
31
    {
32 6
        return 'idx';
33
    }
34
35 6
    protected function buildDescription()
36
    {
37 6
        return parent::buildDescription() + ['unique' => $this->unique];
38
    }
39
}
40