Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

MyZik May 17th, 2020 924 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace App\Manager;
  4.  
  5. use App\Entity\Category;
  6.  
  7. class ProductManager
  8. {
  9.     /**
  10.      * @var int
  11.      */
  12.     public $count;
  13.  
  14.     public function __construct()
  15.     {
  16.         $this->count = 0;
  17.     }
  18.  
  19.     /**
  20.      * @param Category|null $category
  21.      * @return int
  22.      */
  23.     public function getItemsCountFotCategory(?Category $category): int
  24.     {
  25.         foreach ($category->getChildren() as $child)
  26.         {
  27.             if ($category->getProducts() !== null) {
  28.                 $this->count += $category->getProducts()->count();
  29.             }
  30.  
  31.             if ($child->getChildren() !== null) {
  32.                 $this->getItemsCountFotCategory($child);
  33.             } else {
  34.                 continue;
  35.             }
  36.         }
  37.  
  38.         return $this->count;
  39.     }
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top