Skip to content

Commit

Permalink
Added UploadedMarkableInterface on AbstactStorableFile
Browse files Browse the repository at this point in the history
To help indicate the setUploaded() method
  • Loading branch information
Coen Zimmerman committed Jan 9, 2019
1 parent 089ec7e commit 34531b8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
14 changes: 14 additions & 0 deletions src/Contracts/Storage/UploadedMarkableInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
namespace Czim\FileHandling\Contracts\Storage;

interface UploadedMarkableInterface
{

/**
* Marks the file as having been uploaded (or not).
*
* @param bool $uploaded
*/
public function setUploaded($uploaded = true);

}
3 changes: 2 additions & 1 deletion src/Storage/File/AbstractStorableFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
namespace Czim\FileHandling\Storage\File;

use Czim\FileHandling\Contracts\Storage\StorableFileInterface;
use Czim\FileHandling\Contracts\Storage\UploadedMarkableInterface;

abstract class AbstractStorableFile implements StorableFileInterface
abstract class AbstractStorableFile implements StorableFileInterface, UploadedMarkableInterface
{

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Storage/File/StorableFileFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,12 @@ public function makeFromRawData($data, $name = null, $mimeType = null)
}

/**
* @param AbstractStorableFile $file
* @return AbstractStorableFile
* @param StorableFileInterface|UploadedMarkableInterface $file
* @return StorableFileInterface
*/
protected function getReturnPreparedFile(AbstractStorableFile $file)
protected function getReturnPreparedFile(StorableFileInterface $file)
{
if ($this->markNextUploaded) {
if ($this->markNextUploaded && $file instanceof UploadedMarkableInterface) {
$file->setUploaded();
$this->markNextUploaded = false;
}
Expand Down

0 comments on commit 34531b8

Please sign in to comment.