Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
theimerj authored and actions-user committed Nov 20, 2021
1 parent cb91b1b commit 2152aa0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
26 changes: 13 additions & 13 deletions src/Madnest/Madzipper/Repositories/RepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
namespace Madnest\Madzipper\Repositories;

/**
* RepositoryInterface that needs to be implemented by every Repository
* RepositoryInterface that needs to be implemented by every Repository.
*
* Class RepositoryInterface
*/
interface RepositoryInterface
{
/**
* Construct with a given path
* Construct with a given path.
*
* @param $filePath
* @param bool $new
Expand All @@ -19,37 +19,37 @@ interface RepositoryInterface
public function __construct($filePath, $new = false, $archiveImplementation = null);

/**
* Add a file to the opened Archive
* Add a file to the opened Archive.
*
* @param $pathToFile
* @param $pathInArchive
*/
public function addFile($pathToFile, $pathInArchive);

/**
* Add a file to the opened Archive using its contents
* Add a file to the opened Archive using its contents.
*
* @param $name
* @param $content
*/
public function addFromString($name, $content);

/**
* Add an empty directory
* Add an empty directory.
*
* @param $dirName
*/
public function addEmptyDir($dirName);

/**
* Remove a file permanently from the Archive
* Remove a file permanently from the Archive.
*
* @param $pathInArchive
*/
public function removeFile($pathInArchive);

/**
* Get the content of a file
* Get the content of a file.
*
* @param $pathInArchive
*
Expand All @@ -58,7 +58,7 @@ public function removeFile($pathInArchive);
public function getFileContent($pathInArchive);

/**
* Get the stream of a file
* Get the stream of a file.
*
* @param $pathInArchive
*
Expand All @@ -68,14 +68,14 @@ public function getFileStream($pathInArchive);

/**
* Will loop over every item in the archive and will execute the callback on them
* Will provide the filename for every item
* Will provide the filename for every item.
*
* @param $callback
*/
public function each($callback);

/**
* Checks whether the file is in the archive
* Checks whether the file is in the archive.
*
* @param $fileInArchive
*
Expand All @@ -84,7 +84,7 @@ public function each($callback);
public function fileExists($fileInArchive);

/**
* Sets the password to be used for decompressing
* Sets the password to be used for decompressing.
*
* @param $password
*
Expand All @@ -93,14 +93,14 @@ public function fileExists($fileInArchive);
public function usePassword($password);

/**
* Returns the status of the archive as a string
* Returns the status of the archive as a string.
*
* @return string
*/
public function getStatus();

/**
* Closes the archive and saves it
* Closes the archive and saves it.
*/
public function close();
}
28 changes: 14 additions & 14 deletions src/Madnest/Madzipper/Repositories/ZipRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ZipRepository implements RepositoryInterface
private $archive;

/**
* Construct with a given path
* Construct with a given path.
*
* @param $filePath
* @param bool $create
Expand All @@ -30,12 +30,12 @@ public function __construct($filePath, $create = false, $archive = null)

$res = $this->archive->open($filePath, ($create ? ZipArchive::CREATE : null));
if ($res !== true) {
throw new Exception("Error: Failed to open $filePath! Error: " . $this->getErrorMessage($res));
throw new Exception("Error: Failed to open $filePath! Error: ".$this->getErrorMessage($res));
}
}

/**
* Add a file to the opened Archive
* Add a file to the opened Archive.
*
* @param $pathToFile
* @param $pathInArchive
Expand All @@ -46,7 +46,7 @@ public function addFile($pathToFile, $pathInArchive)
}

/**
* Add an empty directory
* Add an empty directory.
*
* @param $dirName
*/
Expand All @@ -56,7 +56,7 @@ public function addEmptyDir($dirName)
}

/**
* Add a file to the opened Archive using its contents
* Add a file to the opened Archive using its contents.
*
* @param $name
* @param $content
Expand All @@ -67,7 +67,7 @@ public function addFromString($name, $content)
}

/**
* Remove a file permanently from the Archive
* Remove a file permanently from the Archive.
*
* @param $pathInArchive
*/
Expand All @@ -77,7 +77,7 @@ public function removeFile($pathInArchive)
}

/**
* Get the content of a file
* Get the content of a file.
*
* @param $pathInArchive
*
Expand All @@ -89,7 +89,7 @@ public function getFileContent($pathInArchive)
}

/**
* Get the stream of a file
* Get the stream of a file.
*
* @param $pathInArchive
*
Expand All @@ -102,13 +102,13 @@ public function getFileStream($pathInArchive)

/**
* Will loop over every item in the archive and will execute the callback on them
* Will provide the filename for every item
* Will provide the filename for every item.
*
* @param $callback
*/
public function each($callback)
{
for ($i = 0; $i < $this->archive->numFiles; ++$i) {
for ($i = 0; $i < $this->archive->numFiles; $i++) {
//skip if folder
$stats = $this->archive->statIndex($i);
if ($stats['size'] === 0 && $stats['crc'] === 0) {
Expand All @@ -119,7 +119,7 @@ public function each($callback)
}

/**
* Checks whether the file is in the archive
* Checks whether the file is in the archive.
*
* @param $fileInArchive
*
Expand All @@ -132,7 +132,7 @@ public function fileExists($fileInArchive)

/**
* Sets the password to be used for decompressing
* function named usePassword for clarity
* function named usePassword for clarity.
*
* @param $password
*
Expand All @@ -144,7 +144,7 @@ public function usePassword($password)
}

/**
* Returns the status of the archive as a string
* Returns the status of the archive as a string.
*
* @return string
*/
Expand All @@ -154,7 +154,7 @@ public function getStatus()
}

/**
* Closes the archive and saves it
* Closes the archive and saves it.
*/
public function close()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Repositories/ZipRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function it_throws_an_exception_when_trying_to_open_something_else_than_a
{
$this->expectException(Exception::class);
$this->expectExceptionMessageMatches('/Error: Failed to open (.*)ZipRepositoryTest.php! Error: ZipArchive::ER_NOZIP - Not a zip archive./');
new ZipRepository(__DIR__ . DIRECTORY_SEPARATOR . 'ZipRepositoryTest.php', false);
new ZipRepository(__DIR__.DIRECTORY_SEPARATOR.'ZipRepositoryTest.php', false);
}

/**
Expand Down

0 comments on commit 2152aa0

Please sign in to comment.