Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

Compression Method Name updated #11

Merged
merged 1 commit into from
Jan 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions lib/Compression/CompressionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,17 @@ class CompressionManager implements CompressionManagerInterface
*/
public function addCompressionAlgorithm(CompressionInterface $compression_algorithm)
{
$this->compression_algorithms[] = $compression_algorithm;
$this->compression_algorithms[$compression_algorithm->getMethodName()] = $compression_algorithm;

return $this;
}

/**
* @param string $name
* @return mixed
* @return CompressionInterface|null
*/
public function getCompressionAlgorithm($name)
{
foreach ($this->compression_algorithms as $algorithm) {
if ($algorithm->isMethodSupported($name)) {
return $algorithm;
}
}
return array_key_exists($name, $this->compression_algorithms)?$this->compression_algorithms[$name]:null;
}
}
7 changes: 3 additions & 4 deletions lib/Compression/Deflate.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ public function getCompressionLevel()
}

/**
* @param string $method
* @return bool
* @return string
*/
public function isMethodSupported($method)
public function getMethodName()
{
return 'DEF' === $method;
return 'DEF';
}

/**
Expand Down
7 changes: 3 additions & 4 deletions lib/Compression/GZip.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ public function getCompressionLevel()
}

/**
* @param string $method
* @return bool
* @return string
*/
public function isMethodSupported($method)
public function getMethodName()
{
return 'GZ' === $method;
return 'GZ';
}

/**
Expand Down
7 changes: 3 additions & 4 deletions lib/Compression/ZLib.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ public function getCompressionLevel()
}

/**
* @param string $method
* @return bool
* @return string
*/
public function isMethodSupported($method)
public function getMethodName()
{
return 'ZLIB' === $method;
return 'ZLIB';
}

/**
Expand Down