Passed
Push — master ( 9a32f5...bdf634 )
by
unknown
01:04 queued 17s
created

View::isVerticalDisplayNeeded()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
16
 *
17
 * PHP version 5
18
 *
19
 * @category  Payone
20
 * @package   Payone_Magento2_Plugin
21
 * @author    FATCHIP GmbH <[email protected]>
22
 * @copyright 2003 - 2016 Payone GmbH
23
 * @license   <http://www.gnu.org/licenses/> GNU Lesser General Public License
24
 * @link      http://www.payone.de
25
 */
26
27
namespace Payone\Core\Block\Adminhtml\Protocol\Api;
28
29
use Payone\Core\Model\Entities\ApiLog;
30
31
/**
32
 * Class for API-log grid block
33
 */
34
class View extends \Magento\Backend\Block\Widget\Container
0 ignored issues
show
Bug introduced by
The type Magento\Backend\Block\Widget\Container 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...
35
{
36
    /**
37
     * Requested ApiLog-entry
38
     *
39
     * @var \Payone\Core\Model\Entities\ApiLog
40
     */
41
    protected $oApiLog = null;
42
43
    /**
44
     * ApiLog factory
45
     *
46
     * @var \Payone\Core\Model\Entities\ApiLogFactory
0 ignored issues
show
Bug introduced by
The type Payone\Core\Model\Entities\ApiLogFactory 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...
47
     */
48
    protected $apiLogFactory;
49
50
    /**
51
     * Constructor
52
     *
53
     * @param \Magento\Backend\Block\Widget\Context     $context
54
     * @param \Payone\Core\Model\Entities\ApiLogFactory $apiLogFactory
55
     * @param array                                     $data
56
     */
57
    public function __construct(
58
        \Magento\Backend\Block\Widget\Context $context,
0 ignored issues
show
Bug introduced by
The type Magento\Backend\Block\Widget\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...
59
        \Payone\Core\Model\Entities\ApiLogFactory $apiLogFactory,
60
        array $data = []
61
    ) {
62
        parent::__construct($context, $data);
63
        $this->apiLogFactory = $apiLogFactory;
64
    }
65
66
    /**
67
     * Returns the currently requested ApiLog-object
68
     *
69
     * @return ApiLog
70
     */
71
    public function getApiLogEntry()
72
    {
73
        if ($this->oApiLog === null) {
74
            $oApiLog = $this->apiLogFactory->create();
75
            $oApiLog->load($this->getRequest()->getParam('id'));
76
            $this->oApiLog = $oApiLog;
77
        }
78
        return $this->oApiLog;
79
    }
80
81
    public function isVerticalDisplayNeeded()
82
    {
83
        // not done and used yet, but may be useful in the future
84
        if (false) { // add criteria ti discern between horizontal and vertical display
85
            return true;
86
        }
87
        return false;
88
    }
89
90
    /**
91
     * Adding the Back button
92
     *
93
     * @return void
94
     */
95
    protected function _construct()
96
    {
97
        $this->buttonList->add(
98
            'back',
99
            [
100
                'label' => __('Back'),
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

100
                'label' => /** @scrutinizer ignore-call */ __('Back'),
Loading history...
101
                'onclick' => "setLocation('".$this->getUrl('payone/protocol_api/')."')",
102
                'class' => 'back'
103
            ]
104
        );
105
        parent::_construct();
106
    }
107
108
    /**
109
     * Used to format the value for certain keys differently
110
     *
111
     * @param  string $sKey
112
     * @param  string $sValue
113
     * @return string
114
     */
115
    public function formatValue($sKey, $sValue)
116
    {
117
        if (in_array($sKey, ['add_paydata[amazon_address_token]', 'add_paydata[paymentmethod_token_data]'])) {
118
            return '<span title="'.$sValue.'">[...]</span>';
119
        }
120
        return $sValue;
121
    }
122
}
123