Skip to content

Commit d2a69f3

Browse files
authored
ENGCOM-3567: Clean code #18124
2 parents 6f2fd68 + 656c431 commit d2a69f3

File tree

16 files changed

+152
-91
lines changed

16 files changed

+152
-91
lines changed

app/code/Magento/Catalog/Ui/Component/ColumnFactory.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\Catalog\Ui\Component;
77

88
/**
9+
* Column Factory
10+
*
911
* @api
1012
* @since 100.0.2
1113
*/
@@ -47,10 +49,14 @@ public function __construct(\Magento\Framework\View\Element\UiComponentFactory $
4749
}
4850

4951
/**
52+
* Create Factory
53+
*
5054
* @param \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute
5155
* @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context
5256
* @param array $config
57+
*
5358
* @return \Magento\Ui\Component\Listing\Columns\ColumnInterface
59+
* @throws \Magento\Framework\Exception\LocalizedException
5460
*/
5561
public function create($attribute, $context, array $config = [])
5662
{
@@ -82,7 +88,10 @@ public function create($attribute, $context, array $config = [])
8288
}
8389

8490
/**
91+
* Get Js Component
92+
*
8593
* @param string $dataType
94+
*
8695
* @return string
8796
*/
8897
protected function getJsComponent($dataType)
@@ -91,14 +100,15 @@ protected function getJsComponent($dataType)
91100
}
92101

93102
/**
103+
* Get Data Type
104+
*
94105
* @param \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute
106+
*
95107
* @return string
96108
*/
97109
protected function getDataType($attribute)
98110
{
99-
return isset($this->dataTypeMap[$attribute->getFrontendInput()])
100-
? $this->dataTypeMap[$attribute->getFrontendInput()]
101-
: $this->dataTypeMap['default'];
111+
return $this->dataTypeMap[$attribute->getFrontendInput()] ?? $this->dataTypeMap['default'];
102112
}
103113

104114
/**
@@ -111,6 +121,6 @@ protected function getFilterType($frontendInput)
111121
{
112122
$filtersMap = ['date' => 'dateRange'];
113123
$result = array_replace_recursive($this->dataTypeMap, $filtersMap);
114-
return isset($result[$frontendInput]) ? $result[$frontendInput] : $result['default'];
124+
return $result[$frontendInput] ?? $result['default'];
115125
}
116126
}

app/code/Magento/Catalog/Ui/Component/Listing/Columns/Thumbnail.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Magento\Framework\View\Element\UiComponent\ContextInterface;
1010

1111
/**
12+
* Class Thumbnail
13+
*
1214
* @api
1315
* @since 100.0.2
1416
*/
@@ -67,13 +69,15 @@ public function prepareDataSource(array $dataSource)
6769
}
6870

6971
/**
72+
* Get Alt
73+
*
7074
* @param array $row
7175
*
7276
* @return null|string
7377
*/
7478
protected function getAlt($row)
7579
{
7680
$altField = $this->getData('config/altField') ?: self::ALT_FIELD;
77-
return isset($row[$altField]) ? $row[$altField] : null;
81+
return $row[$altField] ?? null;
7882
}
7983
}

app/code/Magento/CatalogUrlRewrite/Model/ObjectRegistry.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\CatalogUrlRewrite\Model;
77

8+
/**
9+
* Class ObjectRegistry
10+
*/
811
class ObjectRegistry
912
{
1013
/**
@@ -26,15 +29,19 @@ public function __construct($entities)
2629
}
2730

2831
/**
32+
* Get Entity
33+
*
2934
* @param int $entityId
3035
* @return \Magento\Framework\DataObject|null
3136
*/
3237
public function get($entityId)
3338
{
34-
return isset($this->entitiesMap[$entityId]) ? $this->entitiesMap[$entityId] : null;
39+
return $this->entitiesMap[$entityId] ?? null;
3540
}
3641

3742
/**
43+
* List Entities
44+
*
3845
* @return \Magento\Framework\DataObject[]
3946
*/
4047
public function getList()

app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Sales.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,12 @@ public function _beforeToHtml()
147147
*/
148148
public function getWebsiteCount($websiteId)
149149
{
150-
return isset($this->_websiteCounts[$websiteId]) ? $this->_websiteCounts[$websiteId] : 0;
150+
return $this->_websiteCounts[$websiteId] ?? 0;
151151
}
152152

153153
/**
154+
* Returns Grouped Collection Rows
155+
*
154156
* @return array
155157
*/
156158
public function getRows()
@@ -159,6 +161,8 @@ public function getRows()
159161
}
160162

161163
/**
164+
* Return totals data
165+
*
162166
* @return \Magento\Framework\DataObject
163167
*/
164168
public function getTotals()
@@ -171,7 +175,9 @@ public function getTotals()
171175
*
172176
* @param float $price
173177
* @param null|int $websiteId
178+
*
174179
* @return string
180+
* @throws \Magento\Framework\Exception\LocalizedException
175181
*/
176182
public function formatCurrency($price, $websiteId = null)
177183
{

app/code/Magento/Customer/Model/Address/AbstractAddress.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public function getStreet()
230230
public function getStreetLine($number)
231231
{
232232
$lines = $this->getStreet();
233-
return isset($lines[$number - 1]) ? $lines[$number - 1] : '';
233+
return $lines[$number - 1] ?? '';
234234
}
235235

236236
/**
@@ -271,8 +271,9 @@ public function setStreet($street)
271271
* Enforce format of the street field or other multiline custom attributes
272272
*
273273
* @param array|string $key
274-
* @param mixed $value
275-
* @return $this
274+
* @param array|string|null $value
275+
*
276+
* @return \Magento\Framework\DataObject
276277
*/
277278
public function setData($key, $value = null)
278279
{
@@ -404,7 +405,7 @@ public function getRegionCode()
404405
}
405406

406407
/**
407-
* Get region id
408+
* Return Region ID
408409
*
409410
* @return int
410411
*/
@@ -507,7 +508,7 @@ public function getConfig()
507508
}
508509

509510
/**
510-
* Before save handler
511+
* Processing object before save data
511512
*
512513
* @return $this
513514
*/
@@ -523,10 +524,12 @@ public function beforeSave()
523524
*
524525
* @param int|null $defaultBillingAddressId
525526
* @param int|null $defaultShippingAddressId
527+
*
526528
* @return AddressInterface
527529
* Use Api/Data/AddressInterface as a result of service operations. Don't rely on the model to provide
528530
* the instance of Api/Data/AddressInterface
529531
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
532+
* @throws \Magento\Framework\Exception\LocalizedException
530533
*/
531534
public function getDataModel($defaultBillingAddressId = null, $defaultShippingAddressId = null)
532535
{
@@ -633,6 +636,7 @@ public function unsRegion()
633636
*
634637
* @return bool
635638
* @since 100.2.0
639+
* @throws \Magento\Framework\Exception\LocalizedException
636640
*/
637641
protected function isCompanyRequired()
638642
{
@@ -644,6 +648,7 @@ protected function isCompanyRequired()
644648
*
645649
* @return bool
646650
* @since 100.2.0
651+
* @throws \Magento\Framework\Exception\LocalizedException
647652
*/
648653
protected function isTelephoneRequired()
649654
{
@@ -655,6 +660,7 @@ protected function isTelephoneRequired()
655660
*
656661
* @return bool
657662
* @since 100.2.0
663+
* @throws \Magento\Framework\Exception\LocalizedException
658664
*/
659665
protected function isFaxRequired()
660666
{

app/code/Magento/Fedex/Model/Carrier.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,7 @@ public function getCode($type, $code = '')
986986
* Return FeDex currency ISO code by Magento Base Currency Code
987987
*
988988
* @return string 3-digit currency code
989+
* @throws \Magento\Framework\Exception\NoSuchEntityException
989990
*/
990991
public function getCurrencyCode()
991992
{
@@ -1008,7 +1009,7 @@ public function getCurrencyCode()
10081009
];
10091010
$currencyCode = $this->_storeManager->getStore()->getBaseCurrencyCode();
10101011

1011-
return isset($codes[$currencyCode]) ? $codes[$currencyCode] : $currencyCode;
1012+
return $codes[$currencyCode] ?? $currencyCode;
10121013
}
10131014

10141015
/**
@@ -1438,6 +1439,8 @@ protected function _doShipmentRequest(\Magento\Framework\DataObject $request)
14381439
}
14391440

14401441
/**
1442+
* Return Tracking Number
1443+
*
14411444
* @param array|object $trackingIds
14421445
* @return string
14431446
*/
@@ -1452,10 +1455,10 @@ function ($val) {
14521455
}
14531456

14541457
/**
1455-
* For multi package shipments. Delete requested shipments if the current shipment
1456-
* request is failed
1458+
* For multi package shipments. Delete requested shipments if the current shipment request is failed
14571459
*
14581460
* @param array $data
1461+
*
14591462
* @return bool
14601463
*/
14611464
public function rollBack($data)
@@ -1475,6 +1478,7 @@ public function rollBack($data)
14751478
* Return container types of carrier
14761479
*
14771480
* @param \Magento\Framework\DataObject|null $params
1481+
*
14781482
* @return array|bool
14791483
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
14801484
*/
@@ -1542,6 +1546,7 @@ public function getContainerTypesFilter()
15421546
* Return delivery confirmation types of carrier
15431547
*
15441548
* @param \Magento\Framework\DataObject|null $params
1549+
*
15451550
* @return array
15461551
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
15471552
*/
@@ -1552,6 +1557,7 @@ public function getDeliveryConfirmationTypes(\Magento\Framework\DataObject $para
15521557

15531558
/**
15541559
* Recursive replace sensitive fields in debug data by the mask
1560+
*
15551561
* @param string $data
15561562
* @return string
15571563
*/
@@ -1569,6 +1575,7 @@ protected function filterDebugData($data)
15691575

15701576
/**
15711577
* Parse track details response from Fedex
1578+
*
15721579
* @param \stdClass $trackInfo
15731580
* @return array
15741581
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -1639,6 +1646,7 @@ private function processTrackingDetails(\stdClass $trackInfo)
16391646

16401647
/**
16411648
* Parse delivery datetime from tracking details
1649+
*
16421650
* @param \stdClass $trackInfo
16431651
* @return \Datetime|null
16441652
*/
@@ -1655,8 +1663,7 @@ private function getDeliveryDateTime(\stdClass $trackInfo)
16551663
}
16561664

16571665
/**
1658-
* Get delivery address details in string representation
1659-
* Return City, State, Country Code
1666+
* Get delivery address details in string representation Return City, State, Country Code
16601667
*
16611668
* @param \stdClass $address
16621669
* @return \Magento\Framework\Phrase|string
@@ -1718,6 +1725,7 @@ private function processTrackDetailsEvents(array $events)
17181725

17191726
/**
17201727
* Append error message to rate result instance
1728+
*
17211729
* @param string $trackingValue
17221730
* @param string $errorMessage
17231731
*/
@@ -1759,8 +1767,7 @@ private function parseDate($timestamp)
17591767
}
17601768

17611769
/**
1762-
* Defines payment type by request.
1763-
* Two values are available: RECIPIENT or SENDER.
1770+
* Defines payment type by request. Two values are available: RECIPIENT or SENDER.
17641771
*
17651772
* @param DataObject $request
17661773
* @return string

app/code/Magento/InstantPurchase/PaymentMethodIntegration/IntegrationFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ public function create(VaultPaymentInterface $paymentMethod, int $storeId): Inte
6565
/**
6666
* Reads value from config.
6767
*
68-
* @param $config
68+
* @param array $config
6969
* @param string $field
7070
* @param string $default
7171
* @return string
7272
*/
7373
private function extractFromConfig($config, string $field, string $default): string
7474
{
75-
return isset($config[$field]) ? $config[$field] : $default;
75+
return $config[$field] ?? $default;
7676
}
7777
}

0 commit comments

Comments
 (0)