Status::disable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Status Trait
6
 * @category    Ticaje
7
 * @package     Ticaje_Setting
8
 * @author      Hector Luis Barrientos <[email protected]>
9
 */
10
11
namespace Ticaje\Configuration\Traits;
12
13
use Magento\Store\Model\ScopeInterface;
14
15
/**
16
 * Trait Status
17
 * @package Ticaje\Configuration\Traits
18
 * Classes using this trait must implement Ticaje\Configuration\GeneralInterface
19
 */
20
trait Status
21
{
22
    /**
23
     * @inheritDoc
24
     */
25
    public function isEnabled($storeId = null): bool
26
    {
27
        $field = self::XML_FIELD_ENABLED;
0 ignored issues
show
Bug introduced by
The constant Ticaje\Configuration\Tra...atus::XML_FIELD_ENABLED was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
28
        $config = $this->scopeConfig->getValue($this->getXmlGeneralPath($field), ScopeInterface::SCOPE_STORE, $storeId) ?: '';
0 ignored issues
show
Bug introduced by
It seems like getXmlGeneralPath() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        $config = $this->scopeConfig->getValue($this->/** @scrutinizer ignore-call */ getXmlGeneralPath($field), ScopeInterface::SCOPE_STORE, $storeId) ?: '';
Loading history...
29
        return (bool)$config;
30
    }
31
32
    /**
33
     * @inheritDoc
34
     */
35
    public function enable($storeId = null)
36
    {
37
        $value = (string)(int)(bool)self::ENABLED_VALUE;
0 ignored issues
show
Bug introduced by
The constant Ticaje\Configuration\Traits\Status::ENABLED_VALUE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
38
        $this->setValue(self::XML_FIELD_ENABLED, $value, $storeId);
0 ignored issues
show
Bug introduced by
The constant Ticaje\Configuration\Tra...atus::XML_FIELD_ENABLED was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
It seems like setValue() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
        $this->/** @scrutinizer ignore-call */ 
39
               setValue(self::XML_FIELD_ENABLED, $value, $storeId);
Loading history...
39
    }
40
41
    /**
42
     * @inheritDoc
43
     */
44
    public function disable($storeId = null)
45
    {
46
        $value = (string)(int)(bool)self::DISABLED_VALUE;
0 ignored issues
show
Bug introduced by
The constant Ticaje\Configuration\Traits\Status::DISABLED_VALUE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
47
        $this->setValue(self::XML_FIELD_ENABLED, $value, $storeId);
0 ignored issues
show
Bug introduced by
The constant Ticaje\Configuration\Tra...atus::XML_FIELD_ENABLED was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
48
    }
49
}
50