Chumper\Zipper\Zipper::getFileContent PHP Method

getFileContent() public method

Gets the content of a single file if available
public getFileContent ( $filePath ) : mixed
$filePath string The full path (including all folders) of the file in the zip
return mixed returns the content or throws an exception
    public function getFileContent($filePath)
    {
        if ($this->repository->fileExists($filePath) === false) {
            throw new Exception(sprintf('The file "%s" cannot be found', $filePath));
        }
        return $this->repository->getFileContent($filePath);
    }

Usage Example

Beispiel #1
0
 public function testNavigationFolderAndHome()
 {
     $this->archive->folder('foo/bar');
     $this->assertEquals('foo/bar', $this->archive->getCurrentFolderPath());
     //----
     $this->file->shouldReceive('isFile')->with('foo')->andReturn(true);
     $this->archive->add('foo');
     $this->assertEquals('foo/bar/foo', $this->archive->getFileContent('foo/bar/foo'));
     //----
     $this->file->shouldReceive('isFile')->with('bar')->andReturn(true);
     $this->archive->home()->add('bar');
     $this->assertEquals('bar', $this->archive->getFileContent('bar'));
     //----
     $this->file->shouldReceive('isFile')->with('baz/bar/bing')->andReturn(true);
     $this->archive->folder('test')->add('baz/bar/bing');
     $this->assertEquals('test/bing', $this->archive->getFileContent('test/bing'));
 }
All Usage Examples Of Chumper\Zipper\Zipper::getFileContent