code: private function getFolderSize($path)
      {
          $size = 0;
  
          foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $directory) {
              /** @var  \SplFileInfo  $directory */
              $size += $directory->getSize();
          }
  
          return $size;
      }
docs: Get the folder size.
  
  @param  string  $path
  
  @return int