Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions src/Alchemy/Zippy/AdapterInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

/*
* This file is part of Zippy.
*
* (c) Alchemy <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Alchemy\Zippy;

use Alchemy\Zippy\ArchiveInterface;
use Alchemy\Zippy\Exception\InvalidArgumentException;
use Alchemy\Zippy\Exception\RuntimeException;
use Alchemy\Zippy\Options;

Interface AdapterInterface
{
/**
* Returns the adapter name
*
* @return String
*/
public function getName();

/**
* Returns the adapter options
*
* @return Options
*/
public function getOptions();

/**
* Sets adapter options
*
* @param Options $option
*
* @return AdapterInterface
*/
public function setOptions(Options $option);

/**
* Opens an archive
*
* @param String $path The path to the archive
*
* @return ArchiveInterface
*
* @throws InvalidArgumentException In case the provided path is not valid
* @throws RuntimeException In case of failure
*/
public function open($path);

/**
* Creates a new archive
*
* @param String $path The path to the archive
*
* @return ArchiveInterface
*
* @throws RuntimeException In case of failure
*/
public function create($path);

/**
* Tests adapter support for current environment
*
* @return Boolean
*/
public static function isSupported();
}
57 changes: 57 additions & 0 deletions src/Alchemy/Zippy/ArchiveInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

/*
* This file is part of Zippy.
*
* (c) Alchemy <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Alchemy\Zippy;

use Alchemy\Zippy\Exception\InvalidArgumentException;
use Alchemy\Zippy\Exception\RuntimeException;
use Alchemy\Zippy\FileInterface;

interface ArchiveInterface
{
/**
* Adds a file into the archive
*
* @param String|\SplFileInfo $source The path to the file
* @param String|null $target The archive file path, null to use the same as source
*
* @return ArchiveInterface
*
* @throws InvalidArgumentException In case the provided source path is not valid
* @throws RuntimeException In case of failure
*/
public function add($source, $target = null);

/**
* Adds a directory into the archive

* @param String|\SplFileInfo $source The path to the directory
* @param String|null $target The directory file path, null to use the same as source
* @param Boolean $recursive Recurse into directories
*
* @return ArchiveInterface
*
* @throws InvalidArgumentException In case the provided source path is not valid
* @throws RuntimeException In case of failure
*/
public function addDirectory($source, $target = null, $recursive = true);

/**
* Removes a file from the archive
*
* @param FileInterface $file The file to remove
*
* @return ArchiveInterface
*
* @throws RuntimeException In case of failure
*/
public function remove(FileInterface $file);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Zippy\Exception;
namespace Alchemy\Zippy\Exception;

interface ExceptionInterface
{
Expand Down
16 changes: 16 additions & 0 deletions src/Alchemy/Zippy/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of Zippy.
*
* (c) Alchemy <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Alchemy\Zippy\Exception;

class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Zippy\Exception;
namespace Alchemy\Zippy\Exception;

class RuntimeException extends \RuntimeException implements ExceptionInterface
{
Expand Down
52 changes: 52 additions & 0 deletions src/Alchemy/Zippy/FileInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/*
* This file is part of Zippy.
*
* (c) Alchemy <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Alchemy\Zippy;

use Alchemy\Zippy\Exception\RuntimeException;

class FileInterface
{
/**
* Gets the location of a file
*
* @return String
*/
public function getLocation();

/**
* Extracts a file from the archive to the given path
*
* @throws RuntimeException In case the extraction failed
*/
public function extract($target);

/**
* Tells whether the current file is a directory or not
*
* @return Boolean
*/
public function isDir();

/**
* Relocates a file with the given path
*
* @return FileInterface
*
* @throws RuntimeException In case of failure
*/
public function rename($location);

/**
* @inheritdoc
*/
public function __toString();
}
16 changes: 16 additions & 0 deletions src/Alchemy/Zippy/Options.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of Zippy.
*
* (c) Alchemy <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Alchemy\Zippy;

class Options
{
}