Completed
Push — master ( 7a734f...debc59 )
by Samuel
8s
created

CustomStructure::getActiveRowClass()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
3
namespace SimpleMapper;
4
5
class CustomStructure implements Structure
6
{
7
    /** @var array */
8
    protected $data = [];
9
10
    /**
11
     * Add row class to table
12
     * @param string $table
13
     * @param string $class
14
     * @return CustomStructure
15
     */
16 50
    public function addActiveRowClass($table, $class)
17
    {
18 50
        $this->data[$table]['row'] = $class;
19 50
        return $this;
20
    }
21
22
    /**
23
     * Add selection class to table
24
     * @param string $table
25
     * @param string $class
26
     * @return CustomStructure
27
     */
28 50
    public function addSelectionClass($table, $class)
29
    {
30 50
        $this->data[$table]['selection'] = $class;
31 50
        return $this;
32
    }
33
34
    /**
35
     * Fetch row class by table
36
     * @param string $table
37
     * @return string
38
     */
39 30
    public function getActiveRowClass($table)
40
    {
41 30
        return isset($this->data[$table]['row'])
42 30
            ? $this->data[$table]['row']
43 30
            : ActiveRow::class;
44
    }
45
46
    /**
47
     * Fetch selection class by table
48
     * @param string $table
49
     * @return string
50
     */
51 8
    public function getSelectionClass($table)
52
    {
53 8
        return isset($this->data[$table]['selection'])
54 8
            ? $this->data[$table]['selection']
55 8
            : Selection::class;
56
    }
57
}
58