Code Duplication    Length = 15-16 lines in 2 locations

src/AppBundle/Controller/Orders/OrdersController.php 1 location

@@ 241-255 (lines=15) @@
238
     * @param \AppBundle\Entity\Orders\Orders   $orders   La commande à traiter
239
     * @param \Doctrine\Common\Persistence\ObjectManager $etm Entity Manager
240
     */
241
    private function saveOrdersArticles($articles, $orders, $etm)
242
    {
243
        foreach ($articles as $article) {
244
            $ordersArticles = new OrdersArticles();
245
            $ordersArticles->setOrders($orders);
246
            $ordersArticles->setArticle($article);
247
            $ordersArticles->setUnitStorage($article->getUnitStorage());
248
            if ($article->getMinstock() > $article->getQuantity()) {
249
                $ordersArticles->setQuantity($article->getMinstock() - $article->getQuantity());
250
            }
251
            $ordersArticles->setPrice($article->getPrice());
252
            $ordersArticles->setTva($article->getTva());
253
            $etm->persist($ordersArticles);
254
        }
255
    }
256
257
    /**
258
     * Print the current order.<br />Creating a `PDF` file for viewing on paper

src/AppBundle/Controller/Stocks/InventoryController.php 1 location

@@ 331-346 (lines=16) @@
328
     * @param \AppBundle\Entity\Stocks\Inventory $inventory
329
     * @param \Doctrine\Common\Persistence\ObjectManager $etm
330
     */
331
    private function saveInventoryArticles(array $articles, Inventory $inventory, ObjectManager $etm)
332
    {
333
        foreach ($articles as $article) {
334
            foreach ($article->getZoneStorages()->getSnapshot() as $zoneStorage) {
335
                $inventoryArticles = new InventoryArticles();
336
                $inventoryArticles->setArticle($article);
337
                $inventoryArticles->setInventory($inventory);
338
                $inventoryArticles->setQuantity($article->getQuantity());
339
                $inventoryArticles->setRealstock(0);
340
                $inventoryArticles->setUnitStorage($article->getUnitStorage());
341
                $inventoryArticles->setPrice($article->getPrice());
342
                $inventoryArticles->setZoneStorage($zoneStorage->getName());
343
                $etm->persist($inventoryArticles);
344
            }
345
        }
346
    }
347
}
348