mirror of
https://gh.wpcy.net/https://github.com/djav1985/v-wordpress-plugin-updater.git
synced 2026-05-01 11:12:18 +08:00
50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Respect\Validation\Exceptions;
|
|
|
|
use function count;
|
|
|
|
/**
|
|
* @author Henrique Moody <henriquemoody@gmail.com>
|
|
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
|
|
*/
|
|
final class KeySetException extends GroupedValidationException implements NonOmissibleException
|
|
{
|
|
public const STRUCTURE = 'structure';
|
|
public const STRUCTURE_EXTRA = 'structure_extra';
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
protected $defaultTemplates = [
|
|
self::MODE_DEFAULT => [
|
|
self::NONE => 'All of the required rules must pass for {{name}}',
|
|
self::SOME => 'These rules must pass for {{name}}',
|
|
self::STRUCTURE => 'Must have keys {{keys}}',
|
|
self::STRUCTURE_EXTRA => 'Must not have keys {{extraKeys}}',
|
|
],
|
|
];
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
protected function chooseTemplate(): string
|
|
{
|
|
if (count($this->getParam('extraKeys'))) {
|
|
return self::STRUCTURE_EXTRA;
|
|
}
|
|
|
|
if (count($this->getChildren()) === 0) {
|
|
return self::STRUCTURE;
|
|
}
|
|
|
|
return parent::chooseTemplate();
|
|
}
|
|
}
|