Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from chrismichaels84/develop
Merge Develop into Master for v0.8.6
- Loading branch information
Showing
46 changed files
with
1,711 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
build | ||
composer.lock | ||
vendor | ||
|
||
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file | ||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file | ||
# composer.lock | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
namespace Michaels\Manager\Bags; | ||
|
||
use Michaels\Manager\Exceptions\BadFileInfoObjectException; | ||
|
||
/** | ||
* Class FileBag - a collection object needed to create SplFileInfo objects from file references, in order to inject | ||
* into the FileLoader. This collection class can only store SplFileInfo objects. Anything else will cause exceptions. | ||
* | ||
* @package Michaels\Manager\Bags | ||
*/ | ||
class FileBag | ||
{ | ||
/** | ||
* @var array An array of SplFileInfo objects | ||
*/ | ||
protected $fileObjects = []; | ||
|
||
/** | ||
* Constructs a new FileBag | ||
* @param $arrayOfSplFileInfoObjects | ||
*/ | ||
public function __construct(array $arrayOfSplFileInfoObjects = []) | ||
{ | ||
$this->initialize($arrayOfSplFileInfoObjects); | ||
} | ||
|
||
/** | ||
* Return an array of SplFileInfo objects | ||
* @return array | ||
*/ | ||
public function getAllFileInfoObjects() | ||
{ | ||
return $this->fileObjects; | ||
} | ||
|
||
/** | ||
* Reset the FileBag back to an empty array. | ||
* @return array - an empty array | ||
*/ | ||
public function emptyBag() | ||
{ | ||
$this->fileObjects = []; | ||
return $this->fileObjects; | ||
} | ||
|
||
/** | ||
* Set up the bag with a proper array of SplFileInfo objects | ||
* @param array $splFileInfoObjects | ||
* @internal param $arrayOfSplFileInfoObjects | ||
*/ | ||
protected function initialize(array $splFileInfoObjects = []) | ||
{ | ||
if (!empty($splFileInfoObjects)) { | ||
foreach ($splFileInfoObjects as $object) { | ||
if ($this->isSplFileInfoObject($object)) { | ||
array_push($this->fileObjects, $object); | ||
} else { | ||
throw new BadFileInfoObjectException('The input array does not hold proper SplFileInfo objects.'); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Check for an \SplFileInfo object | ||
* @param $object | ||
* @return bool | ||
*/ | ||
protected function isSplFileInfoObject($object) | ||
{ | ||
return ($object instanceof \SplFileInfo); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
namespace Michaels\Manager\Contracts; | ||
|
||
/** | ||
* Contract for Decoders | ||
* @package Michaels\Manager | ||
*/ | ||
|
||
interface DecoderInterface | ||
{ | ||
/** | ||
* This is the method, which does the decoding work. | ||
* | ||
* @param $data | ||
* @return array | ||
*/ | ||
public function decode($data); | ||
|
||
/** | ||
* The data returned is the actual file extensions supported for the files to decode. | ||
* For instance, if you want to decode Yaml files with the extensions ".yml" and ".yaml", | ||
* then you want to set the return array to ['yaml', 'yml']. | ||
* | ||
* @return array | ||
*/ | ||
public function getMimeType(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
namespace Michaels\Manager\Contracts; | ||
|
||
/** | ||
* API Methods for loading file data into the manager | ||
* | ||
* See src/Traits/LoadsFilesTrait.php for implementation example | ||
*/ | ||
|
||
interface LoadsFilesInterface | ||
{ | ||
/** | ||
* This method adds load file functionality. | ||
* | ||
* @param array $files an array of SplFileInfo Objects | ||
* @param $append boolean | ||
* @return array | ||
*/ | ||
public function loadFiles(array $files, $append = false); | ||
|
||
/** | ||
* Allows for the addition of a custom decoder to load custom files.. | ||
* | ||
* @param DecoderInterface $decoder | ||
* @return mixed | ||
*/ | ||
public function addDecoder(DecoderInterface $decoder); | ||
} |
Oops, something went wrong.