diff --git a/docs/list-of-rules.md b/docs/list-of-rules.md index af2aeb47..2998d884 100644 --- a/docs/list-of-rules.md +++ b/docs/list-of-rules.md @@ -207,7 +207,7 @@ - [Alpha](rules/Alpha.md) - [Base64](rules/Base64.md) - [Charset](rules/Charset.md) -- [Cntrl](rules/Cntrl.md) +- [Control](rules/Control.md) - [Consonant](rules/Consonant.md) - [Contains](rules/Contains.md) - [ContainsAny](rules/ContainsAny.md) @@ -290,7 +290,7 @@ - [Charset](rules/Charset.md) - [Cnh](rules/Cnh.md) - [Cnpj](rules/Cnpj.md) -- [Cntrl](rules/Cntrl.md) +- [Control](rules/Control.md) - [Consonant](rules/Consonant.md) - [Contains](rules/Contains.md) - [ContainsAny](rules/ContainsAny.md) diff --git a/docs/rules/Alnum.md b/docs/rules/Alnum.md index c9c5de0a..df2bd3a1 100644 --- a/docs/rules/Alnum.md +++ b/docs/rules/Alnum.md @@ -42,7 +42,7 @@ See also: - [Alpha](Alpha.md) - [Charset](Charset.md) -- [Cntrl](Cntrl.md) +- [Control](Control.md) - [Consonant](Consonant.md) - [Digit](Digit.md) - [Lowercase](Lowercase.md) diff --git a/docs/rules/Cntrl.md b/docs/rules/Control.md similarity index 67% rename from docs/rules/Cntrl.md rename to docs/rules/Control.md index 110780da..126fb838 100644 --- a/docs/rules/Cntrl.md +++ b/docs/rules/Control.md @@ -1,13 +1,13 @@ -# Cntrl +# Control -- `Cntrl()` -- `Cntrl(string ...$additionalChars)` +- `Control()` +- `Control(string ...$additionalChars)` Validates if all of the characters in the provided string, are control characters. ```php -v::cntrl()->validate("\n\r\t"); // true +v::control()->validate("\n\r\t"); // true ``` ## Categorization @@ -18,6 +18,7 @@ v::cntrl()->validate("\n\r\t"); // true Version | Description --------|------------- + 2.0.0 | Renamed from `Cntrl` to `Control` 0.5.0 | Created *** diff --git a/docs/rules/Printable.md b/docs/rules/Printable.md index fe91fa0c..e61473b0 100644 --- a/docs/rules/Printable.md +++ b/docs/rules/Printable.md @@ -22,6 +22,6 @@ Version | Description *** See also: -- [Cntrl](Cntrl.md) +- [Control](Control.md) - [Graph](Graph.md) - [Punct](Punct.md) diff --git a/docs/rules/Punct.md b/docs/rules/Punct.md index 1cf0c855..ad06a35b 100644 --- a/docs/rules/Punct.md +++ b/docs/rules/Punct.md @@ -22,6 +22,6 @@ Version | Description *** See also: -- [Cntrl](Cntrl.md) +- [Control](Control.md) - [Graph](Graph.md) - [Printable](Printable.md) diff --git a/docs/rules/Space.md b/docs/rules/Space.md index ecb1417d..f0081dfc 100644 --- a/docs/rules/Space.md +++ b/docs/rules/Space.md @@ -22,4 +22,4 @@ Version | Description *** See also: -- [Cntrl](Cntrl.md) +- [Control](Control.md) diff --git a/library/Exceptions/CntrlException.php b/library/Exceptions/ControlException.php similarity index 93% rename from library/Exceptions/CntrlException.php rename to library/Exceptions/ControlException.php index c50ac9e6..9228c219 100644 --- a/library/Exceptions/CntrlException.php +++ b/library/Exceptions/ControlException.php @@ -18,7 +18,7 @@ namespace Respect\Validation\Exceptions; * @author Danilo Correa * @author Henrique Moody */ -final class CntrlException extends FilteredValidationException +final class ControlException extends FilteredValidationException { /** * {@inheritDoc} diff --git a/library/Rules/Cntrl.php b/library/Rules/Control.php similarity index 94% rename from library/Rules/Cntrl.php rename to library/Rules/Control.php index a1b702b4..2dbd66e4 100644 --- a/library/Rules/Cntrl.php +++ b/library/Rules/Control.php @@ -23,7 +23,7 @@ use function ctype_cntrl; * @author Henrique Moody * @author Nick Lombard */ -final class Cntrl extends AbstractFilterRule +final class Control extends AbstractFilterRule { /** * {@inheritDoc} diff --git a/library/Validator.php b/library/Validator.php index 6aaad420..8e257500 100644 --- a/library/Validator.php +++ b/library/Validator.php @@ -45,7 +45,7 @@ use function count; * @method static Validator charset(string ...$charset) * @method static Validator cnh() * @method static Validator cnpj() - * @method static Validator cntrl(string ...$additionalChars) + * @method static Validator control(string ...$additionalChars) * @method static Validator consonant(string ...$additionalChars) * @method static Validator contains($containsValue, bool $identical = false) * @method static Validator containsAny(array $needles, bool $strictCompareArray = false) diff --git a/tests/integration/rules/cntrl.phpt b/tests/integration/rules/cntrl.phpt index 6c266533..55dbc3aa 100644 --- a/tests/integration/rules/cntrl.phpt +++ b/tests/integration/rules/cntrl.phpt @@ -7,54 +7,54 @@ declare(strict_types=1); require_once 'vendor/autoload.php'; -use Respect\Validation\Exceptions\CntrlException; +use Respect\Validation\Exceptions\ControlException; use Respect\Validation\Exceptions\NestedValidationException; use Respect\Validation\Validator as v; try { - v::cntrl()->check('16-50'); -} catch (CntrlException $exception) { + v::control()->check('16-50'); +} catch (ControlException $exception) { echo $exception->getMessage().PHP_EOL; } try { - v::cntrl('16')->check('16-50'); -} catch (CntrlException $exception) { + v::control('16')->check('16-50'); +} catch (ControlException $exception) { echo $exception->getMessage().PHP_EOL; } try { - v::not(v::cntrl())->check("\n"); -} catch (CntrlException $exception) { + v::not(v::control())->check("\n"); +} catch (ControlException $exception) { echo $exception->getMessage().PHP_EOL; } try { - v::not(v::cntrl('16'))->check("16\n"); -} catch (CntrlException $exception) { + v::not(v::control('16'))->check("16\n"); +} catch (ControlException $exception) { echo $exception->getMessage().PHP_EOL; } try { - v::cntrl()->assert('Foo'); + v::control()->assert('Foo'); } catch (NestedValidationException $exception) { echo $exception->getFullMessage().PHP_EOL; } try { - v::cntrl('Bar')->assert('Foo'); + v::control('Bar')->assert('Foo'); } catch (NestedValidationException $exception) { echo $exception->getFullMessage().PHP_EOL; } try { - v::not(v::cntrl())->assert("\n"); + v::not(v::control())->assert("\n"); } catch (NestedValidationException $exception) { echo $exception->getFullMessage().PHP_EOL; } try { - v::not(v::cntrl('Bar'))->assert("Bar\n"); + v::not(v::control('Bar'))->assert("Bar\n"); } catch (NestedValidationException $exception) { echo $exception->getFullMessage().PHP_EOL; } diff --git a/tests/unit/Rules/CntrlTest.php b/tests/unit/Rules/ControlTest.php similarity index 50% rename from tests/unit/Rules/CntrlTest.php rename to tests/unit/Rules/ControlTest.php index f4ab373a..6628c1a9 100644 --- a/tests/unit/Rules/CntrlTest.php +++ b/tests/unit/Rules/ControlTest.php @@ -20,7 +20,7 @@ use stdClass; * @group rule * * @covers \Respect\Validation\Rules\AbstractFilterRule - * @covers \Respect\Validation\Rules\Cntrl + * @covers \Respect\Validation\Rules\Control * * @author Andre Ramaciotti * @author Gabriel Caruso @@ -28,22 +28,22 @@ use stdClass; * @author Nick Lombard * @author Pascal Borreli */ -final class CntrlTest extends RuleTestCase +final class ControlTest extends RuleTestCase { /** * {@inheritDoc} */ public function providerForValidInput(): array { - $cntrl = new Cntrl(); + $sut = new Control(); return [ - '\n' => [$cntrl, "\n"], - '\r' => [$cntrl, "\r"], - '\t' => [$cntrl, "\t"], - '\n\r\t' => [$cntrl, "\n\r\t"], - 'Ignoring all characters' => [new Cntrl('!@#$%^&*(){} '), '!@#$%^&*(){} '], - 'Ignoring some characters' => [new Cntrl('[]?+=/\\-_|"\',<>. '), "[]?+=/\\-_|\"',<>. \t \n"], + '\n' => [$sut, "\n"], + '\r' => [$sut, "\r"], + '\t' => [$sut, "\t"], + '\n\r\t' => [$sut, "\n\r\t"], + 'Ignoring all characters' => [new Control('!@#$%^&*(){} '), '!@#$%^&*(){} '], + 'Ignoring some characters' => [new Control('[]?+=/\\-_|"\',<>. '), "[]?+=/\\-_|\"',<>. \t \n"], ]; } @@ -52,20 +52,20 @@ final class CntrlTest extends RuleTestCase */ public function providerForInvalidInput(): array { - $cntrl = new Cntrl(); + $sut = new Control(); return [ - 'empty parameter' => [$cntrl, ''], - '16-50' => [$cntrl, '16-50'], - 'a' => [$cntrl, 'a'], - 'white space' => [$cntrl, ' '], - 'Foo' => [$cntrl, 'Foo'], - '12.1' => [$cntrl, '12.1'], - '"-12"' => [$cntrl, '-12'], - '-12' => [$cntrl, -12], - 'alganet' => [$cntrl, 'alganet'], - 'empty array parameter' => [$cntrl, []], - 'object' => [$cntrl, new stdClass()], + 'empty parameter' => [$sut, ''], + '16-50' => [$sut, '16-50'], + 'a' => [$sut, 'a'], + 'white space' => [$sut, ' '], + 'Foo' => [$sut, 'Foo'], + '12.1' => [$sut, '12.1'], + '"-12"' => [$sut, '-12'], + '-12' => [$sut, -12], + 'alganet' => [$sut, 'alganet'], + 'empty array parameter' => [$sut, []], + 'object' => [$sut, new stdClass()], ]; } }