Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Applied phpcs and phpmd rules #37

Closed
wants to merge 10 commits into from
27 changes: 21 additions & 6 deletions App/Response/FeedContent.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Tweakwise (https://www.tweakwise.com/) - All Rights Reserved
*
Expand All @@ -8,6 +9,7 @@

namespace Tweakwise\Magento2TweakwiseExport\App\Response;

use Magento\Framework\Filesystem\DriverInterface;
use Magento\Store\Api\Data\StoreInterface;
use Tweakwise\Magento2TweakwiseExport\Model\Export;
use Tweakwise\Magento2TweakwiseExport\Model\Logger;
Expand All @@ -18,8 +20,6 @@
* Class FeedContent
*
* To string wrapper so output is not stored in memory but written to output on get content
*
* @package Tweakwise\Magento2TweakwiseExport\App\Response
*/
class FeedContent
{
Expand All @@ -36,18 +36,33 @@ class FeedContent
protected $type;

protected $store;

/**
* @var DriverInterface
*/
protected DriverInterface $driver;

/**
* SomeFeedResponse constructor.
*
* @param Export $export
* @param Logger $log
* @param DriverInterface $driver
* @param StoreInterface|null $store
* @param null $type
*/
public function __construct(Export $export, Logger $log, StoreInterface $store = null, $type = null)
{
public function __construct(
Export $export,
Logger $log,
DriverInterface $driver,
StoreInterface $store = null,
$type = null
) {
$this->export = $export;
$this->log = $log;
$this->type = $type;
$this->store = $store;
$this->driver = $driver;
}

/**
Expand All @@ -57,15 +72,15 @@ public function __construct(Export $export, Logger $log, StoreInterface $store =
*/
public function __toString()
{
$resource = fopen('php://output', 'wb');
$resource = $this->driver->fileOpen('php://output', 'wb');
try {
try {
$this->export->getFeed($resource, $this->store, $this->type);
} catch (Exception $e) {
$this->log->error(sprintf('Failed to get feed due to %s', $e->getMessage()));
}
} finally {
fclose($resource);
$this->driver->fileClose($resource);
}

return '';
Expand Down
8 changes: 5 additions & 3 deletions Block/Config/Form/Field/ExportPriceStart.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Tweakwise (https://www.tweakwise.com/) - All Rights Reserved
*
Expand All @@ -17,7 +18,6 @@
/**
* Class ExportStart
*
* @package Tweakwise\Magento2TweakwiseExport\Block\Config\Form\Field
*
* @method Form getForm();
*/
Expand All @@ -32,10 +32,12 @@ protected function _getElementHtml(AbstractElement $element): string
{
/** @var Button $button */
$button = $this->getForm()->getLayout()->createBlock(Button::class);
$button->setData([
$button->setData(
[
'label' => __('Schedule'),
'onclick' => "setLocation('{$this->getUrl('tweakwise/export/trigger/type/price')}')",
]);
]
);

return $button->toHtml();
}
Expand Down
14 changes: 5 additions & 9 deletions Block/Config/Form/Field/ExportStart.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Tweakwise (https://www.tweakwise.com/) - All Rights Reserved
*
Expand All @@ -14,13 +15,6 @@
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Exception\LocalizedException;

/**
* Class ExportStart
*
* @package Tweakwise\Magento2TweakwiseExport\Block\Config\Form\Field
*
* @method Form getForm();
*/
class ExportStart extends Field
{
/**
Expand All @@ -32,10 +26,12 @@ protected function _getElementHtml(AbstractElement $element): string
{
/** @var Button $button */
$button = $this->getForm()->getLayout()->createBlock(Button::class);
$button->setData([
$button->setData(
[
'label' => __('Schedule'),
'onclick' => "setLocation('{$this->getUrl('tweakwise/export/trigger')}')",
]);
]
);

return $button->toHtml();
}
Expand Down
1 change: 1 addition & 0 deletions Block/Config/Form/Field/ExportState.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Tweakwise (https://www.tweakwise.com/) - All Rights Reserved
*
Expand Down
1 change: 1 addition & 0 deletions Block/Config/Form/Field/ExportStatePrice.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Tweakwise (https://www.tweakwise.com/) - All Rights Reserved
*
Expand Down
1 change: 1 addition & 0 deletions Block/Config/Form/Field/ExportStateStock.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Tweakwise (https://www.tweakwise.com/) - All Rights Reserved
*
Expand Down
8 changes: 5 additions & 3 deletions Block/Config/Form/Field/ExportStockStart.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Tweakwise (https://www.tweakwise.com/) - All Rights Reserved
*
Expand All @@ -17,7 +18,6 @@
/**
* Class ExportStart
*
* @package Tweakwise\Magento2TweakwiseExport\Block\Config\Form\Field
*
* @method Form getForm();
*/
Expand All @@ -32,10 +32,12 @@ protected function _getElementHtml(AbstractElement $element): string
{
/** @var Button $button */
$button = $this->getForm()->getLayout()->createBlock(Button::class);
$button->setData([
$button->setData(
[
'label' => __('Schedule'),
'onclick' => "setLocation('{$this->getUrl('tweakwise/export/trigger/type/stock')}')",
]);
]
);

return $button->toHtml();
}
Expand Down
Loading
Loading