Skip to content

Commit d906576

Browse files
authored
IMA-1434: Codesniffer Warnings (#53)
* Improvements in the codebase, fixing the most relevant warnings.
1 parent 3197dff commit d906576

File tree

20 files changed

+233
-174
lines changed

20 files changed

+233
-174
lines changed

Block/Adminhtml/Form/Field/MaskText.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class MaskText extends \Magento\Framework\Data\Form\Element\Text
1717
* @param CollectionFactory $factoryCollection
1818
* @param Escaper $escaper
1919
* @param array $data
20+
* @return void
2021
*/
2122
public function __construct(
2223
\Magento\Framework\Data\Form\Element\Factory $factoryElement,
@@ -31,6 +32,12 @@ public function __construct(
3132
$this->setValue('');
3233
}
3334

35+
/**
36+
* Mask text removing all but last 4 characters
37+
*
38+
* @param array $data
39+
* @return array
40+
*/
3441
private function maskText($data)
3542
{
3643
if (isset($data["value"])) {

Block/IntegrationScript.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
use Magento\Framework\View\Element\Template\Context;
1414

1515
/**
16-
* Class IntegrationScript
16+
* Class IntegrationScript - Integration script block
1717
*
18-
* @package Impact\Integration\Block
1918
*/
2019
class IntegrationScript extends Template
2120
{

Block/System/Config/Button.php

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Impact: Partnership Cloud for Magento
45
*
@@ -9,33 +10,19 @@
910
namespace Impact\Integration\Block\System\Config;
1011

1112
use Magento\Config\Block\System\Config\Form\Field;
12-
use Magento\Backend\Block\Template\Context;
13+
use Magento\Backend\Block\Widget\Button as ButtonBlock;
1314

1415
/**
15-
* Class Button
16+
* Class Button - Button controller
1617
*
17-
* @package IImpact\Integration\Block\System\Config
1818
*/
1919
class Button extends Field
2020
{
2121
/**
2222
* @var string $_template
2323
*/
2424
protected $_template = 'Impact_Integration::system/config/button.phtml';
25-
26-
/**
27-
* Button constructor.
28-
*
29-
* @param Context $context
30-
* @param array $data
31-
*/
32-
public function __construct(
33-
Context $context,
34-
array $data = []
35-
) {
36-
parent::__construct($context, $data);
37-
}
38-
25+
3926
/**
4027
* Function render.
4128
*
@@ -59,29 +46,26 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
5946

6047
/**
6148
* Function getAjaxUrl.
62-
*
6349
*/
6450
public function getAjaxUrl()
6551
{
6652
return $this->getUrl('Impact_Integration/system_config/button');
6753
}
68-
54+
6955
/**
7056
* Function getButtonHtml.
71-
*
7257
*/
7358
public function getButtonHtml()
7459
{
75-
$button = $this->getLayout()->createBlock(
76-
'Magento\Backend\Block\Widget\Button'
77-
)->setData(
60+
$button = $this->getLayout()->createBlock(ButtonBlock::class)
61+
->setData(
7862
[
7963
'id' => 'btnid',
8064
'class' => 'primary',
8165
'label' => __('Uninstall'),
8266
]
8367
);
84-
68+
8569
return $button->toHtml();
8670
}
8771
}

Block/System/Config/NewPage.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
/**
1515
* Class Button
16-
*
17-
* @package IImpact\Integration\Block\System\Config
1816
*/
1917
class NewPage extends Field
2018
{
@@ -58,39 +56,40 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
5856
return $this->_toHtml();
5957
}
6058

61-
6259
/**
6360
* Function getAjaxUrl.
64-
*
6561
*/
6662
public function getAjaxUrl()
6763
{
6864
return $this->getUrl('Impact_Integration/system_config/button');
6965
}
70-
66+
7167
/**
7268
* Function getButtonHtml.
73-
*
7469
*/
7570
public function getButtonHtml()
7671
{
7772
$button = $this->getLayout()->createBlock(
78-
'Magento\Backend\Block\Widget\Button'
73+
\Magento\Backend\Block\Widget\Button::class
7974
)->setData(
8075
[
8176
'id' => 'btnid',
8277
'class' => 'primary',
8378
'label' => __('Uninstall')
8479
]
8580
);
86-
81+
8782
return $button->toHtml();
8883
}
8984

85+
/**
86+
* Function getButtonHtml.
87+
*/
9088
private function retrieveDataFromDb()
9189
{
9290
$object = \Magento\Framework\App\ObjectManager::getInstance();
93-
$con = $object->get('Magento\Framework\App\ResourceConnection')->getConnection('\Magento\Framework\App\ResourceConnection::DEFAULT');
91+
$con = $object->get(\Magento\Framework\App\ResourceConnection::class)
92+
->getConnection('\Magento\Framework\App\ResourceConnection::DEFAULT');
9493

9594
$results = $con->fetchAll("
9695
SELECT * from core_config_data where path in ('impact_integration/existing_customer/account_sid',
@@ -104,6 +103,11 @@ private function retrieveDataFromDb()
104103
return $results;
105104
}
106105

106+
/**
107+
* Function encapsulateValues.
108+
*
109+
* @param array $results
110+
*/
107111
private function encapsulateValues($results)
108112
{
109113
$var = [];

Controller/Adminhtml/System/Config/Button.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Impact: Partnership Cloud for Magento
45
*
@@ -7,7 +8,7 @@
78
*/
89

910
namespace Impact\Integration\Controller\Adminhtml\System\Config;
10-
11+
1112
use Impact\Integration\Service\ImpactApiService;
1213
use Magento\Integration\Api\IntegrationServiceInterface;
1314
use Magento\Integration\Api\OauthServiceInterface;
@@ -17,19 +18,17 @@
1718
use Magento\Backend\App\Action;
1819

1920
/**
20-
* Class Button
21+
* Class Button - Button controller
2122
*
22-
* @package Impact\Integration\Controller\Adminhtml\System\Config
2323
*/
2424
class Button extends Action
2525
{
2626
/**
2727
* API request endpoint integration
2828
*/
29-
const API_ENDPOINT_UNINSTALL = 'https://saasler-magento-impact.herokuapp.com/uninstall';
29+
protected const API_ENDPOINT_UNINSTALL = 'https://saasler-magento-impact.herokuapp.com/uninstall';
3030

3131
/**
32-
* Integration service
3332
*
3433
* @var \Magento\Integration\Api\IntegrationServiceInterface
3534
*/
@@ -57,7 +56,7 @@ class Button extends Action
5756
/**
5857
* Button constructor.
5958
*
60-
* @param Context $context,
59+
* @param Context $context
6160
* @param LoggerInterface $logger
6261
* @param IntegrationServiceInterface $integrationService
6362
* @param OauthServiceInterface $oauthService
@@ -92,9 +91,14 @@ public function execute()
9291
// Get accesstoken from integration
9392
$token = $this->oauthService->getAccessToken($integration->getConsumerId());
9493
$accessToken = $token->getToken();
95-
94+
9695
// Send request uninstall in saasler
97-
$impactApiService = new ImpactApiService($accessToken, static::API_ENDPOINT_UNINSTALL, 'DELETE', json_encode(['Deleted'=>'yes']));
96+
$impactApiService = new ImpactApiService(
97+
$accessToken,
98+
static::API_ENDPOINT_UNINSTALL,
99+
'DELETE',
100+
json_encode(['Deleted' => 'yes'])
101+
);
98102
$response = $impactApiService->execute();
99103

100104
// Delete integration record

Helper/Data.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Impact: Partnership Cloud for Magento
45
*
@@ -12,37 +13,36 @@
1213
use Magento\Store\Model\ScopeInterface;
1314

1415
/**
15-
* Class Data
16+
* Class Data - Helper for Data
1617
*
17-
* @package Impact\Integration\Helper
1818
*/
1919
class Data extends AbstractHelper
2020
{
2121
/**
22-
* Row in core_config_data table for enable extension
23-
*/
24-
const MODULE_ENABLE_DISABLE = 'impact_integration/general/enabled';
22+
* Row in core_config_data table for enable extension
23+
*/
24+
protected const MODULE_ENABLE_DISABLE = 'impact_integration/general/enabled';
2525

2626
/**
27-
* Row in core_config_data table for conversion url
28-
*/
29-
const XML_CONVERSION_URL_PATH = 'impact_integration/existing_customer/conversion_url';
27+
* Row in core_config_data table for conversion url
28+
*/
29+
protected const XML_CONVERSION_URL_PATH = 'impact_integration/existing_customer/conversion_url';
3030

3131
/**
32-
* Row in core_config_data table for refund url
33-
*/
34-
const XML_REFUND_URL_PATH = 'impact_integration/existing_customer/refund_url';
32+
* Row in core_config_data table for refund url
33+
*/
34+
protected const XML_REFUND_URL_PATH = 'impact_integration/existing_customer/refund_url';
3535

3636
/**
37-
* Row in core_config_data table for utt script
38-
*/
39-
const XML_UTT_DEFAULT_PATH = 'impact_integration/existing_customer/utt_default';
37+
* Row in core_config_data table for utt script
38+
*/
39+
protected const XML_UTT_DEFAULT_PATH = 'impact_integration/existing_customer/utt_default';
4040

41-
/**
42-
* Get conversion url.
43-
*
44-
* @return string
45-
*/
41+
/**
42+
* Get conversion url.
43+
*
44+
* @return string
45+
*/
4646
public function getConversionUrl()
4747
{
4848
return $this->scopeConfig->getValue(static::XML_CONVERSION_URL_PATH);

Model/ConfigData.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
use Magento\Config\Model\ResourceModel\Config;
1313

1414
/**
15-
* Class ConfigData
15+
* Class ConfigData - Model for ConfigData
1616
*
17-
* @package Impact\Integration\Model
1817
*/
1918
class ConfigData
2019
{

Observer/CheckoutOnePageControllerSuccessAction.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
use Impact\Integration\Helper\Data;
1616

1717
/**
18-
* Class CheckoutOnePageControllerSuccessAction
18+
* Class CheckoutOnePageControllerSuccessAction - Observer for CheckoutOnePageControllerSuccessAction
1919
*
20-
* @package Impact\Integration\Observer
2120
*/
2221
class CheckoutOnePageControllerSuccessAction implements ObserverInterface
2322
{
@@ -46,19 +45,27 @@ public function __construct(
4645
}
4746

4847
/**
48+
* Execute Function - Send conversion to Impact
49+
*
4950
* @param EventObserver $observer
5051
* @return $this
5152
*/
5253
public function execute(EventObserver $observer)
5354
{
5455
// Validate if module is enable
55-
if ($this->helper->isEnabled() && !empty($this->helper->getConversionUrl()) && !is_null($this->helper->getConversionUrl())) {
56+
if ($this->helper->isEnabled()
57+
&& !empty($this->helper->getConversionUrl()) && $this->helper->getConversionUrl() !== null) {
5658
// Get data from order
5759
$order = $observer->getEvent()->getOrder();
5860
$entityId = $order->getEntityId();
5961
$irclickid = $this->cookieManager->getCookie('irclickid');
6062

61-
$saaslerApiService = new ImpactApiService('', $this->helper->getConversionUrl(), 'POST', json_encode(['order_id' => $entityId, 'irclickid' => $irclickid]));
63+
$saaslerApiService = new ImpactApiService(
64+
'',
65+
$this->helper->getConversionUrl(),
66+
'POST',
67+
json_encode(['order_id' => $entityId, 'irclickid' => $irclickid])
68+
);
6269
$response = $saaslerApiService->execute();
6370
$responseBody = $response->getBody();
6471
$responseContent = $responseBody->getContents();

0 commit comments

Comments
 (0)