Skip to content

Commit

Permalink
Implement new method Files::getName()
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Jan 24, 2021
1 parent 19920d1 commit 3710d66
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ public function __construct(FilesystemAdapter $fileSystemAdapter)
$this->fileSystemAdapter = $fileSystemAdapter;
}

/**
* @param string $filename
* @return Name
*/
public function getName(string $filename): Name
{
return new Name($filename);
}

/**
* @param string $filename
* @param FormatterInterface|null $formatter
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/FilesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@

use Codeception\Test\Unit;
use League\Flysystem\Local\LocalFilesystemAdapter;
use Phlexus\Files\File\Name;
use Phlexus\Files\Files;
use Phlexus\Files\Formatter\Md5Formatter;

final class FilesTest extends Unit
{
public function testGetName(): void
{
$files = new Files(new LocalFilesystemAdapter(codecept_output_dir()));
$name = $files->getName('filename.jpg');

$this->assertInstanceOf(Name::class, $name);
}

public function testSetFormattedNameMd5(): void
{
$files = new Files(new LocalFilesystemAdapter(codecept_output_dir()));
Expand Down

0 comments on commit 3710d66

Please sign in to comment.