Skip to content

Commit

Permalink
Merge pull request #8 from daniel-de-wit/master
Browse files Browse the repository at this point in the history
Replace and deprecate isFilled() with exists()
  • Loading branch information
czim committed Feb 14, 2018
2 parents 98a5cba + 7d5d730 commit 9cbf5e8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
14 changes: 13 additions & 1 deletion src/Attachment/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public function setToBeDeleted()
*/
public function reprocess($variants = ['*'])
{
if ( ! $this->isFilled()) {
if ( ! $this->exists()) {
return;
}

Expand Down Expand Up @@ -654,9 +654,21 @@ function ($variant) {
/**
* Returns whether this attachment actually has a file currently stored.
*
* @deprecated Use exists() instead
* @see exists
* @return bool
*/
public function isFilled()
{
return $this->exists();
}

/**
* Returns whether this attachment actually has a file currently stored.
*
* @return bool
*/
public function exists()
{
return ! empty($this->originalFilename());
}
Expand Down
9 changes: 9 additions & 0 deletions src/Contracts/AttachmentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,19 @@ public function variantPath($variant = null);
/**
* Returns whether this attachment actually has a file currently stored.
*
* @deprecated Use exists() instead
* @see exists
* @return bool
*/
public function isFilled();

/**
* Returns whether this attachment actually has a file currently stored.
*
* @return bool
*/
public function exists();

/**
* Returns the creation time of the file as originally assigned to this attachment's model.
* Lives in the <attachment>_created_at attribute of the model.
Expand Down
4 changes: 2 additions & 2 deletions tests/Attachment/AttachmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,11 @@ function it_returns_whether_the_attachment_is_filled()
$attachment->setName('attachment');
$attachment->setInstance($model);

static::assertFalse($attachment->isFilled());
static::assertFalse($attachment->exists());

$model->attachment = 'testing';

static::assertTrue($attachment->isFilled());
static::assertTrue($attachment->exists());
}


Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/PaperclipReprocessAttachmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function it_skips_reprocessing_a_variant_if_attachment_is_not_filled()
{
$model = $this->getTestModel();

static::assertFalse($model->image->isFilled());
static::assertFalse($model->image->exists());

$model->image->reprocess();
}
Expand All @@ -34,7 +34,7 @@ function it_reprocesses_variant()
$model->image = new SplFileInfo($this->getTestFilePath('empty.gif'));
$model->save();

static::assertTrue($model->image->isFilled());
static::assertTrue($model->image->exists());
static::assertEquals('empty.gif', $model->image_file_name);

$processedFilePath = $this->getUploadedAttachmentPath($model, 'empty.gif', 'image', 'medium');
Expand Down

0 comments on commit 9cbf5e8

Please sign in to comment.