container = $container; } /** * @param $name * @return mixed|null * @throws \Interop\Container\Exception\ContainerException */ public function __get($name) { if ($this->container->has($name)) { return $this->container->get($name); } return null; } /** * @param $id * @return int */ protected function getUsedSpaceByUser($id): int { $medias = $this->database->query('SELECT `uploads`.`storage_path` FROM `uploads` WHERE `user_id` = ?', $id); $totalSize = 0; $filesystem = $this->storage; foreach ($medias as $media) { try { $totalSize += $filesystem->getSize($media->storage_path); } catch (FileNotFoundException $e) { $this->logger->error('Error calculating file size', ['exception' => $e]); } } return $totalSize; } }