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

Commit

Permalink
Merge pull request #11 from Spomky-Labs/develop
Browse files Browse the repository at this point in the history
Compression Method Name updated
  • Loading branch information
Spomky committed Jan 30, 2015
2 parents 10b26cf + fb6b837 commit 55f5c17
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 24 deletions.
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

0 comments on commit 55f5c17

Please sign in to comment.