Code Duplication    Length = 15-16 lines in 2 locations

src/AppBundle/Controller/InventoryController.php 1 location

@@ 343-358 (lines=16) @@
340
     * @param \AppBundle\Entity\Inventory $inventory
341
     * @param \Doctrine\Common\Persistence\ObjectManager $etm
342
     */
343
    private function saveInventoryArticles(array $articles, Inventory $inventory, ObjectManager $etm)
344
    {
345
        foreach ($articles as $article) {
346
            foreach ($article->getZoneStorages()->getSnapshot() as $zoneStorage) {
347
                $inventoryArticles = new InventoryArticles();
348
                $inventoryArticles->setArticle($article);
349
                $inventoryArticles->setInventory($inventory);
350
                $inventoryArticles->setQuantity($article->getQuantity());
351
                $inventoryArticles->setRealstock(0);
352
                $inventoryArticles->setUnitStorage($article->getUnitStorage());
353
                $inventoryArticles->setPrice($article->getPrice());
354
                $inventoryArticles->setZoneStorage($zoneStorage->getName());
355
                $etm->persist($inventoryArticles);
356
            }
357
        }
358
    }
359
360
    private function closeInventoryArticles($param) {
361
        

src/AppBundle/Controller/OrdersController.php 1 location

@@ 241-255 (lines=15) @@
238
     * @param \AppBundle\Entity\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