diff --git a/Block/System/Config/Form/Field/Version.php b/Block/System/Config/Form/Field/Version.php index a98a00a41d2c1aab88dce26b916e386ce7c11dc7..d3198ed26f29de1c520b6da1cc61ceebc8cbb1a1 100644 --- a/Block/System/Config/Form/Field/Version.php +++ b/Block/System/Config/Form/Field/Version.php @@ -5,9 +5,6 @@ use Magento\Framework\Data\Form\Element\AbstractElement; /** * Displays Version number in System Configuration - * @category BobGroup - * @package BobGo - * @author support@bobgo.co.za * @website https://www.bobgo.co.za */ class Version extends \Magento\Config\Block\System\Config\Form\Field diff --git a/Helper/Data.php b/Helper/Data.php index 85a24f2acfd9378effc0f68de7edca9ffaf1b72a..3b938e697a88c9436b439ab3d68a99a3f22caa77 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -7,9 +7,6 @@ use Magento\Framework\Module\ModuleListInterface; use Magento\Store\Model\ScopeInterface; /** - * @category Bob Go - * @package BobGo - * @author Bob Go * @website https://www.bobgo.co.za */ class Data extends AbstractHelper diff --git a/Model/Carrier/BobGo.php b/Model/Carrier/BobGo.php index faf7d2b166cfbdc482d5e25cac4f5b1c210266c7..0bb07133d122dc77de353f0e7bed32c097eb65fd 100644 --- a/Model/Carrier/BobGo.php +++ b/Model/Carrier/BobGo.php @@ -33,9 +33,6 @@ use Psr\Log\LoggerInterface; /** * Bob Go shipping implementation - * @category Bob Go - * @package BobGo - * @author Bob Go * @website https://www.bobgo.co.za * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -161,7 +158,6 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car JsonFactory $jsonFactory, CurlFactory $curlFactory, array $data = [] - ) { $this->_storeManager = $storeManager; @@ -413,7 +409,7 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car $baseIdentifier = $this->getBaseUrl(); - return array($originStreet, $originRegion, $originCountry, $originCity, $originStreet1, $originStreet2, $storeName, $baseIdentifier, $originSuburb, $weightUnit); + return [$originStreet, $originRegion, $originCountry, $originCity, $originStreet1, $originStreet2, $storeName, $baseIdentifier, $originSuburb, $weightUnit]; } @@ -646,7 +642,6 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car protected function _doShipmentRequest(\Magento\Framework\DataObject $request) { return null; - } /** @@ -794,7 +789,6 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car $rates = $this->uRates($payload); $this->_formatRates($rates, $result); - } /** @@ -969,7 +963,7 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car $destStreet2 = ''; $destStreet3 = ''; } - return array($destStreet1, $destStreet2, $destStreet3); + return [$destStreet1, $destStreet2, $destStreet3]; } /** @@ -1142,5 +1136,4 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car } return false; } - } diff --git a/Model/Carrier/uData.php b/Model/Carrier/uData.php index df3a1686e3fd01edd219516128a84d8b410cd56d..c65039ea0a7bf669061d3e0db11e7b75567e3139 100644 --- a/Model/Carrier/uData.php +++ b/Model/Carrier/uData.php @@ -2,10 +2,6 @@ namespace BobGroup\BobGo\Model\Carrier; -/** - * Class uData - * @package BobGroup\BobGo\Model\Carrier - */ class uData { diff --git a/Model/Source/Freemethod.php b/Model/Source/Freemethod.php index 674f68706a72978fd580ecb1f6ebd157e78b9bfc..30a0429d6f7a3726f4ea44df4d9812a27a63cb7a 100644 --- a/Model/Source/Freemethod.php +++ b/Model/Source/Freemethod.php @@ -8,11 +8,12 @@ namespace BobGroup\BobGo\Model\Source; class Freemethod extends Method { /** - * {@inheritdoc} + * @inheritdoc */ public function toOptionArray() { - //Returns an array of arrays, each of which has a 'value' and a 'label'. The 'value' is the code for the shipping method, and the 'label' is the name of the shipping method. + // Returns an array of arrays, each of which has a 'value' and a 'label'. + // The 'value' is the code for the shipping method, and the 'label' is the name of the shipping method. $arr = parent::toOptionArray(); array_unshift($arr, ['value' => '', 'label' => __('None')]); return $arr; diff --git a/Model/Source/Generic.php b/Model/Source/Generic.php index f5eb3943cd1c7c0f71cc2af44e6361fb0adb1006..4e58598c00c950bb0d1a4a7c100aec4182a87378 100644 --- a/Model/Source/Generic.php +++ b/Model/Source/Generic.php @@ -2,12 +2,11 @@ namespace BobGroup\BobGo\Model\Source; - use Magento\Framework\Data\OptionSourceInterface; use BobGroup\BobGo\Model\Carrier\BobGo; /** - * bobgo generic source implementation + * BobGo generic source implementation. */ class Generic implements OptionSourceInterface { @@ -18,6 +17,7 @@ class Generic implements OptionSourceInterface /** * Carrier code + * * @var string */ protected string $_code = ''; @@ -31,7 +31,8 @@ class Generic implements OptionSourceInterface } /** - * Returns array to be used in multiselect on back-end + * Returns array to be used in multiselect on back-end. + * * @return array */ public function toOptionArray() @@ -53,5 +54,4 @@ class Generic implements OptionSourceInterface return $arr; } - } diff --git a/Model/Source/Unitofmeasure.php b/Model/Source/Unitofmeasure.php index be8d13b0455812d4f308f45a235ab4888eb19aa5..0d77d95b7094f7a95c1bb475742860e3647b7989 100644 --- a/Model/Source/Unitofmeasure.php +++ b/Model/Source/Unitofmeasure.php @@ -9,5 +9,4 @@ class Unitofmeasure extends Generic * @var string */ protected string $_code = 'unit_of_measure'; - } diff --git a/Observer/ConfigChangeObserver.php b/Observer/ConfigChangeObserver.php index b72cb2663f685bebbb0bf8cab19b7726b0cbd043..1e947aec7c9ec0b94f1070e03c6dd9b6e3a4be65 100644 --- a/Observer/ConfigChangeObserver.php +++ b/Observer/ConfigChangeObserver.php @@ -10,10 +10,28 @@ use BobGroup\BobGo\Model\Carrier\BobGo; class ConfigChangeObserver implements ObserverInterface { + /** + * @var BobGo + */ protected $bobGo; + + /** + * @var LoggerInterface + */ protected $logger; + + /** + * @var ManagerInterface + */ protected $messageManager; + /** + * Constructor + * + * @param BobGo $bobGo + * @param LoggerInterface $logger + * @param ManagerInterface $messageManager + */ public function __construct( BobGo $bobGo, LoggerInterface $logger, @@ -24,22 +42,33 @@ class ConfigChangeObserver implements ObserverInterface $this->messageManager = $messageManager; } + /** + * Execute observer to handle configuration changes. + * + * @param Observer $observer + * @return void + */ public function execute(Observer $observer) { $changedPaths = $observer->getEvent()->getData('changed_paths'); if (is_array($changedPaths) && in_array('carriers/bobgo/active', $changedPaths)) { - if ($this->bobGo->isActive()) { $result = $this->bobGo->triggerRatesTest(); if ($result !== false) { - $this->messageManager->addSuccessMessage(__('Bob Go rates at checkout connected.')); + $this->messageManager->addSuccessMessage( + __('Bob Go rates at checkout connected.') + ); } else { - $this->messageManager->addErrorMessage(__('Failed to connect to rates at checkout. Please check your internet connection and make sure Rates at checkout is enabled for your channel on Bob Go. Please visit <a href="https://my.bobgo.co.za/rates-at-checkout?tab=settings" target="_new">Bob Go</a> and make sure your WooCommerce channel is enabled to receive rates.')); + $this->messageManager->addErrorMessage( + __('Failed to connect to rates at checkout. Please check your internet connection and make ' + . 'sure Rates at checkout is enabled for your channel on Bob Go. Please visit ' + . '<a href="https://my.bobgo.co.za/rates-at-checkout?tab=settings" target="_new">Bob ' + . 'Go</a> and make sure your WooCommerce channel is enabled to receive rates.') + ); } } } } - } diff --git a/Plugin/AddWeightUnitToOrderPlugin.php b/Plugin/AddWeightUnitToOrderPlugin.php index d619ddec7cb9d316a808e1d649ea943e37ea0ede..d0e16873de5e8e15370bb2696d02ac1a19a74c63 100644 --- a/Plugin/AddWeightUnitToOrderPlugin.php +++ b/Plugin/AddWeightUnitToOrderPlugin.php @@ -9,9 +9,22 @@ use Magento\Framework\App\Config\ScopeConfigInterface; class AddWeightUnitToOrderPlugin { + /** + * @var LoggerInterface + */ protected $logger; + + /** + * @var ScopeConfigInterface + */ protected $scopeConfig; + /** + * Constructor + * + * @param LoggerInterface $logger + * @param ScopeConfigInterface $scopeConfig + */ public function __construct( LoggerInterface $logger, ScopeConfigInterface $scopeConfig @@ -20,6 +33,13 @@ class AddWeightUnitToOrderPlugin $this->scopeConfig = $scopeConfig; } + /** + * Before save plugin to modify order items' weight based on the configured weight unit. + * + * @param OrderRepositoryInterface $subject + * @param OrderInterface $order + * @return array + */ public function beforeSave( OrderRepositoryInterface $subject, OrderInterface $order @@ -43,7 +63,6 @@ class AddWeightUnitToOrderPlugin } } - return [$order]; } } diff --git a/Plugin/Block/DataProviders/Tracking/ChangeTitle.php b/Plugin/Block/DataProviders/Tracking/ChangeTitle.php index 36eebbc50fb69646ffcbc4ca1fa4e3e959bef859..8498b7a92b4ef8b73bcf6eefe00c1b5ddf3593e7 100644 --- a/Plugin/Block/DataProviders/Tracking/ChangeTitle.php +++ b/Plugin/Block/DataProviders/Tracking/ChangeTitle.php @@ -6,7 +6,6 @@ use BobGroup\BobGo\Model\Carrier; use Magento\Shipping\Model\Tracking\Result\Status; use Magento\Shipping\Block\DataProviders\Tracking\DeliveryDateTitle as Subject; - /** * Plugin to change delivery date title with bobgo customized value */ diff --git a/Plugin/Checkout/Block/LayoutProcessorPlugin.php b/Plugin/Checkout/Block/LayoutProcessorPlugin.php index 1c32fb6afc4d8e9b0956ec0534ad9adc237f88ab..0bf99b1274d015257d0d9408263232671c1dfa73 100644 --- a/Plugin/Checkout/Block/LayoutProcessorPlugin.php +++ b/Plugin/Checkout/Block/LayoutProcessorPlugin.php @@ -5,22 +5,25 @@ use Magento\Checkout\Block\Checkout\LayoutProcessor; /** * Class LayoutProcessorPlugin - * @package BobGroup\BobGo\Plugin\Checkout\Block - * This class is supposed to add a new field to the checkout page for the suburb. It is supposed to be used in conjunction with the SaveOrderBeforeSalesModelQuote observer. - * At the moment, it overrides the 2 Address fields and adds a new 3 Address field to accommodate the suburb on the checkout page( including placeholders). - * This is not the best way to do it, but it is the only way I could get it to work. + * Adds a new field to the checkout page for the suburb. + * + * This class is used in conjunction with the SaveOrderBeforeSalesModelQuote observer. + * It overrides the 2 Address fields and adds a new 3rd Address field to accommodate the suburb + * on the checkout page (including placeholders). + * Note: This implementation, though functional, may not be the most optimal way. */ class LayoutProcessorPlugin { /** + * Modify checkout layout to add suburb field. + * * @param \Magento\Checkout\Block\Checkout\LayoutProcessor $subject * @param array $jsLayout * @return array */ - public function afterProcess( \Magento\Checkout\Block\Checkout\LayoutProcessor $subject, - array $jsLayout + array $jsLayout ) { $suburbAttribute = 'suburb'; $suburb = [ @@ -39,16 +42,18 @@ class LayoutProcessorPlugin 'provider' => 'checkoutProvider', 'sortOrder' => 80, 'validation' => [ - 'required-entry' => true + 'required-entry' => true, ], 'options' => [], 'filterBy' => null, 'customEntry' => null, 'visible' => true, - 'value' => '' // value field is used to set a default value of the attribute + 'value' => '' // Default value for the attribute ]; - $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['shippingAddress']['children']['shipping-address-fieldset']['children'][$suburbAttribute] = $suburb; + $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children'] + ['shippingAddress']['children']['shipping-address-fieldset']['children'][$suburbAttribute] + = $suburb; return $jsLayout; }