Passed
Branch master (acde85)
by Alexander
01:40
created

Wallets::beforeSave()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace B2Binpay\Payment\Model\System\Config\Backend;
4
5
use Magento\Framework\App\Cache\TypeListInterface;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\App\Cache\TypeListInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Magento\Framework\App\Config\ScopeConfigInterface;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\App\Config\ScopeConfigInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Magento\Framework\Data\Collection\AbstractDb;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\Data\Collection\AbstractDb was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Magento\Framework\Model\Context;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\Model\Context was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Magento\Framework\Model\ResourceModel\AbstractResource;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\Model\...eModel\AbstractResource was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Magento\Framework\Registry;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\Registry was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use B2Binpay\Payment\Helper\Wallets as WalletsHelper;
12
13
/**
14
 * Backend for serialized array data
15
 */
16
class Wallets extends \Magento\Framework\App\Config\Value
0 ignored issues
show
Bug introduced by
The type Magento\Framework\App\Config\Value was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
{
18
    /**
19
     * @var WalletsHelper
20
     */
21
    protected $walletsHelper = null;
22
23
    /**
24
     * @param Context $context
25
     * @param Registry $registry
26
     * @param ScopeConfigInterface $config
27
     * @param TypeListInterface $cacheTypeList
28
     * @param WalletsHelper $walletsHelper
29
     * @param AbstractResource $resource
30
     * @param AbstractDb $resourceCollection
31
     * @param array $data
32
     */
33
    public function __construct(
34
        Context $context,
35
        Registry $registry,
36
        ScopeConfigInterface $config,
37
        TypeListInterface $cacheTypeList,
38
        WalletsHelper $walletsHelper,
39
        AbstractResource $resource = null,
40
        AbstractDb $resourceCollection = null,
41
        array $data = []
42
    ) {
43
        $this->walletsHelper = $walletsHelper;
44
        parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
45
    }
46
47
    /**
48
     * Process data after load
49
     *
50
     * @return void
51
     */
52
    protected function _afterLoad()
53
    {
54
        $value = $this->getValue();
55
        $value = $this->walletsHelper->makeArrayFieldValue($value);
56
        $this->setValue($value);
57
    }
58
59
    /**
60
     * Prepare data before save
61
     *
62
     * @return void
63
     */
64
    public function beforeSave()
65
    {
66
        $value = $this->getValue();
67
        $value = $this->walletsHelper->makeStorableArrayFieldValue($value);
68
        $this->setValue($value);
69
    }
70
}
71