Chumper\Zipper\Zipper::remove PHP Method

remove() public method

Remove a file or array of files and folders from the zip archive
public remove ( $fileToRemove )
$fileToRemove array|string The path/array to the files in the zip
    public function remove($fileToRemove)
    {
        if (is_array($fileToRemove)) {
            $self = $this;
            $this->repository->each(function ($file) use($fileToRemove, $self) {
                if (starts_with($file, $fileToRemove)) {
                    $self->getRepository()->removeFile($file);
                }
            });
        } else {
            $this->repository->removeFile($fileToRemove);
        }
        return $this;
    }

Usage Example

Beispiel #1
0
 public function testRemove()
 {
     $this->file->shouldReceive('isFile')->with('foo')->andReturn(true);
     $this->archive->add('foo');
     $this->assertTrue($this->archive->contains('foo'));
     $this->archive->remove('foo');
     $this->assertFalse($this->archive->contains('foo'));
     //----
     $this->file->shouldReceive('isFile')->with('foo')->andReturn(true);
     $this->file->shouldReceive('isFile')->with('fooBar')->andReturn(true);
     $this->archive->add(array('foo', 'fooBar'));
     $this->assertTrue($this->archive->contains('foo'));
     $this->assertTrue($this->archive->contains('fooBar'));
     $this->archive->remove(array('foo', 'fooBar'));
     $this->assertFalse($this->archive->contains('foo'));
     $this->assertFalse($this->archive->contains('fooBar'));
 }
All Usage Examples Of Chumper\Zipper\Zipper::remove