CustomSql::isEnabled()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
namespace SoliDry\Extension;
3
4
use SoliDry\Helpers\ConfigHelper;
5
use SoliDry\Helpers\MigrationsHelper;
6
use SoliDry\Types\ConfigInterface;
7
8
/**
9
 * Class CustomSql
10
 * @package SoliDry\Extension
11
 */
12
class CustomSql
13
{
14
    /**
15
     * @var mixed|null
16
     */
17
    private $entity    = [];
18
    private $isEnabled;
19
20
    /**
21
     * CustomSql constructor.
22
     * @param string $entity
23
     */
24
    public function __construct(string $entity)
25
    {
26
        $this->entity = ConfigHelper::getNestedParam(ConfigInterface::CUSTOM_SQL, MigrationsHelper::getTableName($entity));
27
        if (empty($this->entity[ConfigInterface::ENABLED]) === false) {
28
            $this->isEnabled = $this->entity[ConfigInterface::ENABLED];
29
        }
30
    }
31
32
    /**
33
     * Whether custom sql is enabled or not on this entity
34
     *
35
     * @return mixed
36
     */
37
    public function isEnabled()
38
    {
39
        return $this->isEnabled;
40
    }
41
42
    /**
43
     * Gets the exact query from config for this entity
44
     *
45
     * @return mixed
46
     */
47
    public function getQuery()
48
    {
49
        return $this->entity[ConfigInterface::QUERY];
50
    }
51
52
    /**
53
     * Gets bindings for query
54
     *
55
     * @return mixed
56
     */
57
    public function getBindings()
58
    {
59
        return $this->entity[ConfigInterface::BINDINGS];
60
    }
61
}