Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[#3073] Define filter() in Decompress filter

- and have it mimic __invoke()
  • Loading branch information...
commit 20d61b29f4639e395eb2fa2d222c0079cc193f52 1 parent 35a16ad
Matthew Weier O'Phinney authored
15 library/Zend/Filter/Decompress.php
@@ -19,7 +19,7 @@
19 19 class Decompress extends Compress
20 20 {
21 21 /**
22   - * Defined by Zend_Filter_Filter
  22 + * Use filter as functor
23 23 *
24 24 * Decompresses the content $value with the defined settings
25 25 *
@@ -30,4 +30,17 @@ public function __invoke($value)
30 30 {
31 31 return $this->getAdapter()->decompress($value);
32 32 }
  33 +
  34 + /**
  35 + * Defined by Zend\Filter\FilterInterface
  36 + *
  37 + * Decompresses the content $value with the defined settings
  38 + *
  39 + * @param string $value Content to decompress
  40 + * @return string The decompressed content
  41 + */
  42 + public function filter($value)
  43 + {
  44 + return $this->getAdapter()->decompress($value);
  45 + }
33 46 }
14 tests/ZendTest/Filter/DecompressTest.php
@@ -97,4 +97,18 @@ public function testDecompressArchive()
97 97 $content2 = $filter2($archive);
98 98 $this->assertEquals('compress me', $content2);
99 99 }
  100 +
  101 + public function testFilterMethodProxiesToDecompress()
  102 + {
  103 + $filter = new DecompressFilter('bz2');
  104 + $archive = __DIR__ . '/../_files/compressed.bz2';
  105 + $filter->setArchive($archive);
  106 +
  107 + $content = $filter->compress('compress me');
  108 + $this->assertTrue($content);
  109 +
  110 + $filter2 = new DecompressFilter('bz2');
  111 + $content2 = $filter2->filter($archive);
  112 + $this->assertEquals('compress me', $content2);
  113 + }
100 114 }

0 comments on commit 20d61b2

Please sign in to comment.
Something went wrong with that request. Please try again.