JpgCompressor::class, ]; public function fromMedia(string $mediaPath): Compressor { return $this->resolve(new MediaPath($mediaPath)); } public function resolve(MediaPath $path): Compressor { $mime = mime_content_type($path->root()); $compiler = $this->resolveType($mime); if (is_null($compiler)) { return new $this->default($path); } return new $compiler($path); } private function resolveType(string $type): ?string { return collect($this->types)->get($type); } }