Completed
Pull Request — master (#212)
by Alexandru
10:59
created

Index::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
c 0
b 0
f 0
ccs 0
cts 5
cp 0
rs 10
cc 1
nc 1
nop 3
crap 2
1
<?php
2
3
namespace Rennokki\DynamoDb\ConditionAnalyzer;
4
5
class Index
6
{
7
    /**
8
     * @var string
9
     */
10
    public $name;
11
12
    /**
13
     * @var string
14
     */
15
    public $hash;
16
17
    /**
18
     * @var string
19
     */
20
    public $range;
21
22
    public function __construct($name, $hash, $range)
23
    {
24
        $this->name = $name;
25
        $this->hash = $hash;
26
        $this->range = $range;
27
    }
28
29
    public function isComposite()
30
    {
31
        return isset($this->hash) && isset($this->range);
32
    }
33
34
    public function columns()
35
    {
36
        $columns = [];
37
38
        if ($this->hash) {
39
            $columns[] = $this->hash;
40
        }
41
42
        if ($this->range) {
43
            $columns[] = $this->range;
44
        }
45
46
        return $columns;
47
    }
48
}
49