You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
json2db/app/Enums/FileFormatEnum.php

27 lines
511 B

<?php
namespace App\Enums;
use App\Services\Chunkers\JsonChunker;
use App\Services\Converters\JsonToDatabaseConverter;
enum FileFormatEnum: string
{
case JSON = 'json';
public function chunker($path): \Generator
{
$chunker = match ($this) {
self::JSON => JsonChunker::class
};
return $chunker->handle($path);
}
public function converter()
{
return match($this){
self::JSON => new JsonToDatabaseConverter()
};
}
}