BookStack/app/Exports/ZipExports/ZipValidationHelper.php
2024-10-30 13:13:41 +00:00

33 lines
730 B
PHP

<?php
namespace BookStack\Exports\ZipExports;
use Illuminate\Validation\Factory;
use ZipArchive;
class ZipValidationHelper
{
protected Factory $validationFactory;
public function __construct(
protected ZipArchive $zip,
) {
$this->validationFactory = app(Factory::class);
}
public function validateArray(array $data, array $rules): array
{
return $this->validationFactory->make($data, $rules)->errors()->messages();
}
public function zipFileExists(string $name): bool
{
return $this->zip->statName("files/{$name}") !== false;
}
public function fileReferenceRule(): ZipFileReferenceRule
{
return new ZipFileReferenceRule($this);
}
}