Skip to content
Snippets Groups Projects
Verified Commit b7f74d4c authored by quietone's avatar quietone
Browse files

Issue #3320928 by quietone: Coding standard fixes

parent 517120ad
No related branches found
No related tags found
No related merge requests found
Showing
with 19 additions and 24 deletions
......@@ -43,7 +43,7 @@ class CommerceCustomerProfileReference extends FieldPluginBase {
* {@inheritdoc}
*/
public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) {
$destination_field_name = isset($this->fieldNameMap[$field_name]) ? $this->fieldNameMap[$field_name] : $field_name;
$destination_field_name = $this->fieldNameMap[$field_name] ?? $field_name;
$process = [
'plugin' => 'commerce_migrate_commerce_reference_revision',
'migration' => 'commerce1_profile',
......
......@@ -41,7 +41,7 @@ class CommerceLineItemReference extends FieldPluginBase {
* {@inheritdoc}
*/
public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) {
$destination_field_name = isset($this->fieldNameMap[$field_name]) ? $this->fieldNameMap[$field_name] : $field_name;
$destination_field_name = $this->fieldNameMap[$field_name] ?? $field_name;
$process = [
[
'plugin' => 'migration_lookup',
......
......@@ -64,7 +64,7 @@ class CommercePrice extends FieldPluginBase {
* {@inheritdoc}
*/
public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) {
$destination_field_name = isset($this->fieldNameMap[$field_name]) ? $this->fieldNameMap[$field_name] : $field_name;
$destination_field_name = $this->fieldNameMap[$field_name] ?? $field_name;
$process = [
'plugin' => 'commerce1_migrate_commerce_price',
'source' => $field_name,
......
......@@ -26,7 +26,7 @@ class CommerceAttributeHandlerSetting extends ProcessPluginBase {
('options_select' === $row->getSourceProperty('widget')['type'])) {
$new_handler_settings['target_bundles'][] = $row->getSourceProperty('bundle');
$settings = $row->getDestinationProperty('settings');
$handler_settings = isset($settings['handler_settings']) ? $settings['handler_settings'] : [];
$handler_settings = $settings['handler_settings'] ?? [];
return array_merge($handler_settings, $new_handler_settings);
}
else {
......
......@@ -25,7 +25,7 @@ class CommerceRefreshMode extends ProcessPluginBase {
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$new_value = NULL;
if (is_array($value) && !empty($value)) {
list($force, $refresh_mode) = $value;
[$force, $refresh_mode] = $value;
// If force is true then use the default 'always'.
if ($force) {
......
......@@ -39,7 +39,7 @@ class OrderAdjustmentShipping extends ProcessPluginBase {
throw new MigrateSkipRowException(sprintf("Adjustment currency code does not exist for destination '%s'", $destination_property));
}
$fraction_digits = isset($total['fraction_digits']) ? $total['fraction_digits'] : '2';
$fraction_digits = $total['fraction_digits'] ?? '2';
// Scale the incoming price by the fraction digits.
$input = [
......@@ -53,7 +53,7 @@ class OrderAdjustmentShipping extends ProcessPluginBase {
// Build the adjustment array.
$adjustment = [
'type' => 'shipping',
'label' => isset($value['line_item_label']) ? $value['line_item_label'] : 'Shipping',
'label' => $value['line_item_label'] ?? 'Shipping',
'amount' => $price_scaled['number'],
'currency_code' => $price_scaled['currency_code'],
'sourceId' => 'custom',
......
......@@ -186,7 +186,7 @@ class OrderItemDiscountAdjustment extends CommercePrice implements ContainerFact
throw new MigrateSkipRowException(sprintf("Unknown adjustment type for line item '%s'", $row->getSourceProperty('line_item_id')));
}
// Scale the incoming price by the fraction digits.
$fraction_digits = isset($value['price']['fraction_digits']) ? $value['price']['fraction_digits'] : '2';
$fraction_digits = $value['price']['fraction_digits'] ?? '2';
$input = [
'amount' => $amount,
'fraction_digits' => $fraction_digits,
......
......@@ -51,7 +51,7 @@ class ProductType extends DrupalSqlBase {
->execute()
->fetchCol();
$data = empty($data) ?: unserialize($data[0]);
$line_item_type = isset($data['display']['default']['settings']['line_item_type']) ? $data['display']['default']['settings']['line_item_type'] : '';
$line_item_type = $data['display']['default']['settings']['line_item_type'] ?? '';
$row->setSourceProperty('line_item_type', $line_item_type);
return parent::prepareRow($row);
}
......
......@@ -65,7 +65,7 @@ class FieldInstanceTest extends Commerce1TestBase {
* Whether or not the field is expected to be translatable.
*/
protected function assertEntity($id, $expected_label, $expected_field_type, $is_required, $expected_translatable) {
list ($expected_entity_type, $expected_bundle, $expected_name) = explode('.', $id);
[$expected_entity_type, $expected_bundle, $expected_name] = explode('.', $id);
/** @var \Drupal\field\FieldConfigInterface $field */
$field = FieldConfig::load($id);
......
......@@ -71,7 +71,7 @@ class FieldTest extends Commerce1TestBase {
* The field's dependencies.
*/
protected function assertEntity($id, $type, $translatable, $cardinality, array $dependencies) {
list ($entity_type) = explode('.', $id);
[$entity_type] = explode('.', $id);
/** @var \Drupal\field\FieldStorageConfigInterface $field */
$field = FieldStorageConfig::load($id);
......
......@@ -89,7 +89,7 @@ class PaymentTest extends Commerce1TestBase {
}
elseif ($state_label instanceof TranslatableMarkup) {
$arguments = $state_label->getArguments();
$label = isset($arguments['@label']) ? $arguments['@label'] : $state_label->render();
$label = $arguments['@label'] ?? $state_label->render();
}
$this->assertSame($payment['label_rendered'], $label);
}
......
......@@ -54,7 +54,7 @@ class CommerceOrderItemDiscountAdjustmentTest extends KernelTestBase {
->getMock();
$this->migrateExecutable = $this->getMockBuilder('Drupal\migrate\MigrateExecutable')
->disableOriginalConstructor()
->getMock();;
->getMock();
$entity_type_manager = \Drupal::service('entity_type.manager');
$rounder = new Rounder($entity_type_manager);
$this->plugin = new OrderItemDiscountAdjustment([], 'map', [], $migration, $plugin_manager, $entity_type_manager, $rounder);
......
<?php
namespace Drupal\Tests\commerce_migrate_commerce\Unit\Plugin\migrate\process\commerce1;
use Drupal\commerce_migrate_commerce\Plugin\migrate\process\commerce1\CommercePrice;
use Drupal\commerce_migrate_commerce\Plugin\migrate\process\commerce1\OrderItemDiscountAdjustment;
use Drupal\migrate\MigrateSkipRowException;
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
use Drupal\commerce_price\Price;
......@@ -25,7 +22,6 @@ class CommerceOrderItemDiscountAdjustmentTest extends MigrateProcessTestCase {
*/
protected $rounder;
/**
* Tests Commerce Price plugin.
*
......@@ -55,7 +51,7 @@ class CommerceOrderItemDiscountAdjustmentTest extends MigrateProcessTestCase {
->with('shipping')
->will($this->returnValue($shipping));
$price = new Price ('10', 'NZD');
$price = new Price('10', 'NZD');
$this->rounder->expects($this->at(0))
->method('round')
->with($price)
......
......@@ -38,7 +38,7 @@ class SkipShippingDefault extends ProcessPluginBase {
throw new MigrateException(sprintf("Input should be an array, instead it was of type '%s'", gettype($value)));
}
list($address_default_billing, $address_default_shipping_) = $value;
[$address_default_billing, $address_default_shipping_] = $value;
if ($address_default_shipping_ && !$address_default_billing) {
throw new MigrateSkipRowException('Skip default shipping row.');
}
......
......@@ -50,7 +50,7 @@ class AttributeFieldTest extends Ubercart6TestBase {
* The field's dependencies.
*/
protected function assertEntity($id, $type, $translatable, $cardinality, array $dependencies) {
list ($entity_type) = explode('.', $id);
[$entity_type] = explode('.', $id);
/** @var \Drupal\field\FieldStorageConfigInterface $field */
$field = FieldStorageConfig::load($id);
......
......@@ -49,7 +49,7 @@ class AttributeFieldTest extends Ubercart7TestBase {
* The field's dependencies.
*/
protected function assertEntity($id, $type, $translatable, $cardinality, array $dependencies) {
list ($entity_type) = explode('.', $id);
[$entity_type] = explode('.', $id);
/** @var \Drupal\field\FieldStorageConfigInterface $field */
$field = FieldStorageConfig::load($id);
......
......@@ -9,7 +9,6 @@ use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
*
* @covers \Drupal\commerce_migrate_ubercart\Plugin\migrate\source\Store
*
*
* @group commerce_migrate
* @group commerce_migrate_uc
*/
......
......@@ -260,7 +260,7 @@ trait CommerceMigrateTestTrait {
}
elseif ($state_label instanceof TranslatableMarkup) {
$arguments = $state_label->getArguments();
$label = isset($arguments['@label']) ? $arguments['@label'] : $state_label->render();
$label = $arguments['@label'] ?? $state_label->render();
}
$this->assertSame($order['label_rendered'], $label);
// Allow orders to be tested without a cart.
......@@ -396,7 +396,7 @@ trait CommerceMigrateTestTrait {
}
elseif ($state_label instanceof TranslatableMarkup) {
$arguments = $state_label->getArguments();
$label = isset($arguments['@label']) ? $arguments['@label'] : $state_label->render();
$label = $arguments['@label'] ?? $state_label->render();
}
$this->assertSame($payment['label_rendered'], $label);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment