Skip to content

Commit

Permalink
Implement new method Files::getFormattedFilenameOnly()
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Jan 25, 2021
1 parent 3710d66 commit b719e04
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/File/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ public function getFilenameOnly(): string
return current($parts);
}

/**
* Get formatted file name without extension
*
* @return string
*/
public function getFormattedFilenameOnly(): string
{
$filename = $this->getFilenameOnly();

return $this->getFormatter()->format($filename);
}

/**
* Returns extension name based on filename
*
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/File/NameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,12 @@ public function testFormatTime(): void

$this->assertSame((string)time() . '.jpg', $name->format());
}

public function testGetFormattedFilenameOnly(): void
{
$name = new Name('filename.jpg');
$name->setFormatter(new Md5Formatter());

$this->assertSame('435ed7e9f07f740abf511a62c00eef6e', $name->getFormattedFilenameOnly());
}
}

0 comments on commit b719e04

Please sign in to comment.