vid-queue/app/Data/Casts/Folder.php

20 lines
402 B
PHP
Raw Normal View History

2022-08-19 19:52:56 -05:00
<?php
namespace App\Data\Casts;
use App\Exceptions\Quit;
use Spatie\LaravelData\Casts\Cast;
use Spatie\LaravelData\Support\DataProperty;
class Folder implements Cast
{
public function cast(DataProperty $property, mixed $file, array $context): mixed
{
if (!is_dir($file)) {
throw new Quit("$file is not a valid folder");
}
return realpath($file);
}
}