Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| TextFileFaker | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
| createOriginalFilename | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| createMimeType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isSupported | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| createResource | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\Faker\FileFakers; |
| 3 | |
| 4 | use Apie\Faker\Interfaces\ApieFileFaker; |
| 5 | use Faker\Generator; |
| 6 | use Nyholm\Psr7\Stream; |
| 7 | |
| 8 | final class TextFileFaker implements ApieFileFaker |
| 9 | { |
| 10 | public function createOriginalFilename(Generator $faker): string |
| 11 | { |
| 12 | return $faker->word() . '.txt'; |
| 13 | } |
| 14 | public function createMimeType(): string |
| 15 | { |
| 16 | return 'text/plain'; |
| 17 | } |
| 18 | public static function isSupported(): bool |
| 19 | { |
| 20 | return true; |
| 21 | } |
| 22 | |
| 23 | /** @return resource */ |
| 24 | public function createResource(Generator $faker, string $originalFilename, string $mimeType): mixed |
| 25 | { |
| 26 | return Stream::create($faker->text())->detach(); |
| 27 | } |
| 28 | } |