mirror of
https://github.com/Respect/Validation.git
synced 2024-06-07 00:02:33 +02:00
Use a more consisten names for traits
Because traits are behaviors that are added to a class, it makes sense to name them with the behavior that they add the classes that use them. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
b392fbb92e
commit
73f9380d9e
|
@ -27,7 +27,7 @@ use function mb_strlen;
|
|||
* @author Emmerson Siqueira <emmersonsiqueira@gmail.com>
|
||||
* @author Henrique Moody <henriquemoody@gmail.com>
|
||||
*/
|
||||
trait ComparisonHelper
|
||||
trait CanCompareValues
|
||||
{
|
||||
/**
|
||||
* Tries to convert a value into something that can be compared with PHP operators.
|
|
@ -18,7 +18,7 @@ namespace Respect\Validation\Helpers;
|
|||
*
|
||||
* @author Henrique Moody <henriquemoody@gmail.com>
|
||||
*/
|
||||
trait DateTimeHelper
|
||||
trait CanValidateDateTime
|
||||
{
|
||||
/**
|
||||
* Finds whether a value is a valid date/time in a specific format.
|
|
@ -18,7 +18,7 @@ namespace Respect\Validation\Helpers;
|
|||
*
|
||||
* @author Henrique Moody <henriquemoody@gmail.com>
|
||||
*/
|
||||
trait UndefinedHelper
|
||||
trait CanValidateUndefined
|
||||
{
|
||||
/**
|
||||
* Finds whether the value is undefined or not.
|
|
@ -13,7 +13,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Helpers\DateTimeHelper;
|
||||
use Respect\Validation\Helpers\CanValidateDateTime;
|
||||
use function date;
|
||||
use function date_parse_from_format;
|
||||
use function is_scalar;
|
||||
|
@ -27,7 +27,7 @@ use function vsprintf;
|
|||
*/
|
||||
abstract class AbstractAge extends AbstractRule
|
||||
{
|
||||
use DateTimeHelper;
|
||||
use CanValidateDateTime;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
|
|
|
@ -13,7 +13,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Helpers\ComparisonHelper;
|
||||
use Respect\Validation\Helpers\CanCompareValues;
|
||||
|
||||
/**
|
||||
* Abstract class to help on creating rules that compare value.
|
||||
|
@ -22,7 +22,7 @@ use Respect\Validation\Helpers\ComparisonHelper;
|
|||
*/
|
||||
abstract class AbstractComparison extends AbstractRule
|
||||
{
|
||||
use ComparisonHelper;
|
||||
use CanCompareValues;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
|
|
|
@ -13,7 +13,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Helpers\UndefinedHelper;
|
||||
use Respect\Validation\Helpers\CanValidateUndefined;
|
||||
|
||||
/**
|
||||
* Abstract class for searches into arrays.
|
||||
|
@ -22,7 +22,7 @@ use Respect\Validation\Helpers\UndefinedHelper;
|
|||
*/
|
||||
abstract class AbstractSearcher extends AbstractRule
|
||||
{
|
||||
use UndefinedHelper;
|
||||
use CanValidateUndefined;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
|
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Helpers\ComparisonHelper;
|
||||
use Respect\Validation\Helpers\CanCompareValues;
|
||||
|
||||
/**
|
||||
* Validates whether the input is between two other values.
|
||||
|
@ -24,7 +24,7 @@ use Respect\Validation\Helpers\ComparisonHelper;
|
|||
*/
|
||||
final class Between extends AbstractEnvelope
|
||||
{
|
||||
use ComparisonHelper;
|
||||
use CanCompareValues;
|
||||
|
||||
/**
|
||||
* Initializes the rule.
|
||||
|
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Helpers\DateTimeHelper;
|
||||
use Respect\Validation\Helpers\CanValidateDateTime;
|
||||
use function is_scalar;
|
||||
use function preg_match;
|
||||
use function sprintf;
|
||||
|
@ -27,7 +27,7 @@ use function sprintf;
|
|||
*/
|
||||
final class Date extends AbstractRule
|
||||
{
|
||||
use DateTimeHelper;
|
||||
use CanValidateDateTime;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Respect\Validation\Helpers\DateTimeHelper;
|
||||
use Respect\Validation\Helpers\CanValidateDateTime;
|
||||
use function is_scalar;
|
||||
use function strtotime;
|
||||
|
||||
|
@ -25,7 +25,7 @@ use function strtotime;
|
|||
*/
|
||||
final class DateTime extends AbstractRule
|
||||
{
|
||||
use DateTimeHelper;
|
||||
use CanValidateDateTime;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
|
|
|
@ -13,7 +13,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Helpers\UndefinedHelper;
|
||||
use Respect\Validation\Helpers\CanValidateUndefined;
|
||||
|
||||
/**
|
||||
* Validates if the given input is not optional.
|
||||
|
@ -25,7 +25,7 @@ use Respect\Validation\Helpers\UndefinedHelper;
|
|||
*/
|
||||
final class NotOptional extends AbstractRule
|
||||
{
|
||||
use UndefinedHelper;
|
||||
use CanValidateUndefined;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -13,14 +13,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Helpers\UndefinedHelper;
|
||||
use Respect\Validation\Helpers\CanValidateUndefined;
|
||||
|
||||
/**
|
||||
* @author Henrique Moody <henriquemoody@gmail.com>
|
||||
*/
|
||||
class Optional extends AbstractWrapper
|
||||
{
|
||||
use UndefinedHelper;
|
||||
use CanValidateUndefined;
|
||||
|
||||
public function assert($input): void
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Helpers\DateTimeHelper;
|
||||
use Respect\Validation\Helpers\CanValidateDateTime;
|
||||
use function is_scalar;
|
||||
use function preg_match;
|
||||
use function sprintf;
|
||||
|
@ -26,7 +26,7 @@ use function sprintf;
|
|||
*/
|
||||
final class Time extends AbstractRule
|
||||
{
|
||||
use DateTimeHelper;
|
||||
use CanValidateDateTime;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
|
|
@ -18,13 +18,13 @@ use Respect\Validation\Test\TestCase;
|
|||
/**
|
||||
* @group helper
|
||||
*
|
||||
* @covers \Respect\Validation\Helpers\DateTimeHelper
|
||||
* @covers \Respect\Validation\Helpers\CanValidateDateTime
|
||||
*
|
||||
* @author Henrique Moody <henriquemoody@gmail.com>
|
||||
*/
|
||||
final class DateTimeHelperTest extends TestCase
|
||||
final class CanValidateDateTimeTest extends TestCase
|
||||
{
|
||||
use DateTimeHelper;
|
||||
use CanValidateDateTime;
|
||||
|
||||
public function providerForValidDateTime(): array
|
||||
{
|
|
@ -19,13 +19,13 @@ use Respect\Validation\Test\TestCase;
|
|||
/**
|
||||
* @group helper
|
||||
*
|
||||
* @covers \Respect\Validation\Helpers\UndefinedHelper
|
||||
* @covers \Respect\Validation\Helpers\CanValidateUndefined
|
||||
*
|
||||
* @author Henrique Moody <henriquemoody@gmail.com>
|
||||
*/
|
||||
final class UndefinedHelperTest extends TestCase
|
||||
final class CanValidateUndefinedTest extends TestCase
|
||||
{
|
||||
use UndefinedHelper,
|
||||
use CanValidateUndefined,
|
||||
UndefinedProvider;
|
||||
|
||||
/**
|
Loading…
Reference in a new issue