Completed
Pull Request — master (#5)
by James Ekow Abaka
03:53
created

Index::doesKeyExist()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
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 7
    protected function doesKeyExist($constraint)
16
    {
17 7
        return $this->getDriver()->doesIndexExist($constraint);
18
    }
19
20 7
    protected function addKey($constraint)
21
    {
22 7
        $this->getDriver()->addIndex($constraint);
23 7
    }
24
25
    protected function dropKey($constraint)
26
    {
27
        $this->getDriver()->dropIndex($constraint);
28
    }
29
30 7
    protected function getNamePostfix()
31
    {
32 7
        return 'idx';
33
    }
34
35 7
    protected function buildDescription()
36
    {
37 7
        return parent::buildDescription() + ['unique' => $this->unique];
38
    }
39
}
40