From 53f2b5fa5e3d7499f46a3c22654d868c5ffa86c7 Mon Sep 17 00:00:00 2001 From: Alexandre Granjeon Date: Tue, 28 May 2019 17:03:17 +0200 Subject: [PATCH] reformat code --- Console/Command/Fake.php | 2 +- Model/Faker/Category.php | 4 ++-- Model/Faker/CustomerAddress.php | 5 ++--- Model/Faker/Invoice.php | 4 +--- Model/Faker/Order.php | 5 +++-- Model/Faker/Product.php | 5 +---- Model/Faker/Shipment.php | 9 +++------ 7 files changed, 13 insertions(+), 21 deletions(-) diff --git a/Console/Command/Fake.php b/Console/Command/Fake.php index 38dd72a..ea4be69 100644 --- a/Console/Command/Fake.php +++ b/Console/Command/Fake.php @@ -118,7 +118,7 @@ public function execute(InputInterface $input, OutputInterface $output) $faker->generateFakeData($output); } - return; + break; } $faker = $this->fakerProvider->getFaker($code); $faker->generateFakeData($output); diff --git a/Model/Faker/Category.php b/Model/Faker/Category.php index a971275..a42481a 100644 --- a/Model/Faker/Category.php +++ b/Model/Faker/Category.php @@ -92,7 +92,7 @@ protected function createCategory(int $parentId, int $depth): void } $category = $this->categoryFactory->create(); - $name = ''; + $name = ''; while (strlen($name) < 1) { $name = substr($this->faker->realText(20, 3), 0, -1); } @@ -103,7 +103,7 @@ protected function createCategory(int $parentId, int $depth): void $category->setCustomAttributes( [ 'description' => $this->faker->realText(100, 5), - 'meta_title' => $this->faker->realText(20, 3), + 'meta_title' => $this->faker->realText(20, 3), 'meta_keywords' => $this->faker->realText(50, 5), 'meta_description' => $this->faker->realText(100, 5), ] diff --git a/Model/Faker/CustomerAddress.php b/Model/Faker/CustomerAddress.php index 3861db4..6425f41 100644 --- a/Model/Faker/CustomerAddress.php +++ b/Model/Faker/CustomerAddress.php @@ -78,8 +78,7 @@ public function generateFakeData(OutputInterface $output): void $customers->addFieldToFilter('website_id', ['in' => $this->getStoreConfig('faker/global/website_ids')]); $progressBar = new ProgressBar( - $output->section(), - $customers->getSize() + $output->section(), $customers->getSize() ); $progressBar->setFormat( '%message% %current%/%max% [%bar%] %percent:3s%% %elapsed% %memory:6s%' @@ -94,7 +93,7 @@ public function generateFakeData(OutputInterface $output): void $minAddressNumber = $this->getStoreConfig('faker/customer/min_address_number', $storeId); $maxAddressNumber = $this->getStoreConfig('faker/customer/max_address_number', $storeId); $availableCountryId = explode(',', $this->getStoreConfig('general/country/allow', $storeId)); - $country = $availableCountryId[array_rand($availableCountryId)]; + $country = $availableCountryId[array_rand($availableCountryId)]; $availableRegionId = $this->getAvailableRegionIds($country); $faker = $this->getFaker($storeId); $iterationNumber = $faker->numberBetween($minAddressNumber, $maxAddressNumber); diff --git a/Model/Faker/Invoice.php b/Model/Faker/Invoice.php index 40934eb..87413b4 100644 --- a/Model/Faker/Invoice.php +++ b/Model/Faker/Invoice.php @@ -74,9 +74,7 @@ public function generateFakeData(OutputInterface $output): void if ($faker->boolean($ratio) && $order->canInvoice()) { $invoice = $order->prepareInvoice()->register(); $order->setIsInProcess(true); - $transaction = $this->transactionFactory->create() - ->addObject($invoice) - ->addObject($order); + $transaction = $this->transactionFactory->create()->addObject($invoice)->addObject($order); $transaction->save(); } diff --git a/Model/Faker/Order.php b/Model/Faker/Order.php index 4320a07..f90372d 100644 --- a/Model/Faker/Order.php +++ b/Model/Faker/Order.php @@ -148,7 +148,7 @@ public function generateFakeData(OutputInterface $output): void $product, rand(1, 3) // qty ); - } catch(\Exception $exception) { + } catch (\Exception $exception) { } } if (count($quote->getItemsCollection()->getItems()) == 0) { @@ -170,7 +170,7 @@ public function generateFakeData(OutputInterface $output): void $quote->getPayment()->importData(['method' => $paymentMethod]); $quote->collectTotals()->save(); $this->quoteManagement->submit($quote); - } catch(\Exception $exception) { + } catch (\Exception $exception) { } } $progressBar->advance(); @@ -199,6 +199,7 @@ protected function getProductIds(): array { $collection = $this->productCollectionFactory->create()->addFieldToFilter('status', ['eq' => true]); $this->stockFilter->addIsInStockFilterToCollection($collection); + return $collection->getAllIds(); } } diff --git a/Model/Faker/Product.php b/Model/Faker/Product.php index 9f073b9..6e1ffe8 100644 --- a/Model/Faker/Product.php +++ b/Model/Faker/Product.php @@ -73,10 +73,7 @@ public function generateFakeData(OutputInterface $output): void $websiteIds = explode(',', $this->getStoreConfig('faker/global/website_ids')); $faker = $this->getFaker(0); $categoryIds = $this->categoryCollectionFactory->create()->getAllIds(); - $progressBar = new ProgressBar( - $output->section(), - $numberOfProduct - ); + $progressBar = new ProgressBar($output->section(), $numberOfProduct); $progressBar->setFormat( '%message% %current%/%max% [%bar%] %percent:3s%% %elapsed% %memory:6s%' ); diff --git a/Model/Faker/Shipment.php b/Model/Faker/Shipment.php index 6ff1f18..b3a7b08 100644 --- a/Model/Faker/Shipment.php +++ b/Model/Faker/Shipment.php @@ -87,20 +87,17 @@ public function generateFakeData(OutputInterface $output): void continue; } - $qty = $item->getQtyToShip(); + $qty = $item->getQtyToShip(); $shipmentItem = $this->orderConverter->itemToShipmentItem($item)->setQty($qty); $shipment->addItem($shipmentItem); } $shipment->register(); $order->setIsInProcess(true); - $transaction = $this->transactionFactory->create() - ->addObject($shipment) - ->addObject($order); + $transaction = $this->transactionFactory->create()->addObject($shipment)->addObject($order); $transaction->save(); - } catch(\Exception $exception) { + } catch (\Exception $exception) { } - } $progressBar->advance(); }