Files
animethemes-server/app/Rules/Wiki/Submission/Format/EncoderVersionFormatRule.php
T
paranarimasu 088ea287c5 feat: initial migration to pennant features for feature flags and global site config [incremental] (#573)
* feat: initial commit for feature management

* style: fix StyleCI findings

* fix(api): prohibit features of nonnull scope from API & fix(admin): wrong translate key

* style: fix Static Analysis error
2023-04-23 18:54:34 -05:00

44 lines
983 B
PHP

<?php
declare(strict_types=1);
namespace App\Rules\Wiki\Submission\Format;
use App\Constants\FeatureConstants;
use App\Rules\Wiki\Submission\SubmissionRule;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Arr;
use Laravel\Pennant\Feature;
/**
* Class EncoderVersionFormatRule.
*/
class EncoderVersionFormatRule extends SubmissionRule
{
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param UploadedFile $value
* @return bool
*/
public function passes($attribute, $value): bool
{
$tags = $this->tags();
$encoder = Arr::get($tags, 'encoder');
return version_compare($encoder, Feature::value(FeatureConstants::REQUIRED_ENCODER_VERSION), '>=');
}
/**
* Get the validation error message.
*
* @return string|array
*/
public function message(): string|array
{
return __('validation.submission.format_encoder_version');
}
}