code: public function getSize(bool $recursive = true): int
      {
          $size = 0;
  
          /** @var File $entry */
          foreach ($this->list($recursive)->files($this->storage->getConstraints()) as $file) {
              $size += $file->getSize();
          }
          return $size;
      }
docs: calculate size
  @param bool $recursive
  @return int
  @throws UnexpectedValueException