/** * {@inheritdoc} */ public function compress($data) { if (!$this->selectCompressor()) { throw new \LogicException('Attach at least 1 compressor'); } return $this->selectedCompressor->compress($data); }
/** * {@inheritdoc} */ public function encode($data, CompressorInterface $compressor, array $options = []) { $compressed = base64_encode($compressor->compress($data)); $bin = ''; $length = strlen($compressed); for ($i = 0; $i < $length; $i++) { $bin .= sprintf('%08b', ord($compressed[$i])); } return $bin; }