/** * @param CompressorInterface $compressor * * @throws \RuntimeException * * @return $this */ public function setCompressor(CompressorInterface $compressor) { if (!$compressor->isSupported()) { throw new \RuntimeException('Unsupported type of compressor: ' . $compressor->getName()); } $this->compressor = $compressor; return $this; }
/** * @return bool */ protected function selectCompressor() { if ($this->selectedCompressor) { return true; } if (isset($this->children[$this->options['preferred_choice']])) { $this->selectedCompressor = $this->children[$this->options['preferred_choice']]; if ($this->selectedCompressor->isSupported()) { return true; } } foreach ($this->children as $compressor) { if ($compressor->isSupported()) { $this->selectedCompressor = $compressor; return true; } } return false; }