Rename rule "Cntrl" to "Control"

This commit will rename the rule by removing the abbreviation to make it
a bit easier to understand what it does and much easier to find.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2019-05-11 19:30:47 +02:00
parent 4db2b00f6c
commit 9c0f8dcfcc
No known key found for this signature in database
GPG key ID: 221E9281655813A6
11 changed files with 48 additions and 47 deletions

View file

@ -207,7 +207,7 @@
- [Alpha](rules/Alpha.md) - [Alpha](rules/Alpha.md)
- [Base64](rules/Base64.md) - [Base64](rules/Base64.md)
- [Charset](rules/Charset.md) - [Charset](rules/Charset.md)
- [Cntrl](rules/Cntrl.md) - [Control](rules/Control.md)
- [Consonant](rules/Consonant.md) - [Consonant](rules/Consonant.md)
- [Contains](rules/Contains.md) - [Contains](rules/Contains.md)
- [ContainsAny](rules/ContainsAny.md) - [ContainsAny](rules/ContainsAny.md)
@ -290,7 +290,7 @@
- [Charset](rules/Charset.md) - [Charset](rules/Charset.md)
- [Cnh](rules/Cnh.md) - [Cnh](rules/Cnh.md)
- [Cnpj](rules/Cnpj.md) - [Cnpj](rules/Cnpj.md)
- [Cntrl](rules/Cntrl.md) - [Control](rules/Control.md)
- [Consonant](rules/Consonant.md) - [Consonant](rules/Consonant.md)
- [Contains](rules/Contains.md) - [Contains](rules/Contains.md)
- [ContainsAny](rules/ContainsAny.md) - [ContainsAny](rules/ContainsAny.md)

View file

@ -42,7 +42,7 @@ See also:
- [Alpha](Alpha.md) - [Alpha](Alpha.md)
- [Charset](Charset.md) - [Charset](Charset.md)
- [Cntrl](Cntrl.md) - [Control](Control.md)
- [Consonant](Consonant.md) - [Consonant](Consonant.md)
- [Digit](Digit.md) - [Digit](Digit.md)
- [Lowercase](Lowercase.md) - [Lowercase](Lowercase.md)

View file

@ -1,13 +1,13 @@
# Cntrl # Control
- `Cntrl()` - `Control()`
- `Cntrl(string ...$additionalChars)` - `Control(string ...$additionalChars)`
Validates if all of the characters in the provided string, are control Validates if all of the characters in the provided string, are control
characters. characters.
```php ```php
v::cntrl()->validate("\n\r\t"); // true v::control()->validate("\n\r\t"); // true
``` ```
## Categorization ## Categorization
@ -18,6 +18,7 @@ v::cntrl()->validate("\n\r\t"); // true
Version | Description Version | Description
--------|------------- --------|-------------
2.0.0 | Renamed from `Cntrl` to `Control`
0.5.0 | Created 0.5.0 | Created
*** ***

View file

@ -22,6 +22,6 @@ Version | Description
*** ***
See also: See also:
- [Cntrl](Cntrl.md) - [Control](Control.md)
- [Graph](Graph.md) - [Graph](Graph.md)
- [Punct](Punct.md) - [Punct](Punct.md)

View file

@ -22,6 +22,6 @@ Version | Description
*** ***
See also: See also:
- [Cntrl](Cntrl.md) - [Control](Control.md)
- [Graph](Graph.md) - [Graph](Graph.md)
- [Printable](Printable.md) - [Printable](Printable.md)

View file

@ -22,4 +22,4 @@ Version | Description
*** ***
See also: See also:
- [Cntrl](Cntrl.md) - [Control](Control.md)

View file

@ -18,7 +18,7 @@ namespace Respect\Validation\Exceptions;
* @author Danilo Correa <danilosilva87@gmail.com> * @author Danilo Correa <danilosilva87@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com> * @author Henrique Moody <henriquemoody@gmail.com>
*/ */
final class CntrlException extends FilteredValidationException final class ControlException extends FilteredValidationException
{ {
/** /**
* {@inheritDoc} * {@inheritDoc}

View file

@ -23,7 +23,7 @@ use function ctype_cntrl;
* @author Henrique Moody <henriquemoody@gmail.com> * @author Henrique Moody <henriquemoody@gmail.com>
* @author Nick Lombard <github@jigsoft.co.za> * @author Nick Lombard <github@jigsoft.co.za>
*/ */
final class Cntrl extends AbstractFilterRule final class Control extends AbstractFilterRule
{ {
/** /**
* {@inheritDoc} * {@inheritDoc}

View file

@ -45,7 +45,7 @@ use function count;
* @method static Validator charset(string ...$charset) * @method static Validator charset(string ...$charset)
* @method static Validator cnh() * @method static Validator cnh()
* @method static Validator cnpj() * @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 consonant(string ...$additionalChars)
* @method static Validator contains($containsValue, bool $identical = false) * @method static Validator contains($containsValue, bool $identical = false)
* @method static Validator containsAny(array $needles, bool $strictCompareArray = false) * @method static Validator containsAny(array $needles, bool $strictCompareArray = false)

View file

@ -7,54 +7,54 @@ declare(strict_types=1);
require_once 'vendor/autoload.php'; require_once 'vendor/autoload.php';
use Respect\Validation\Exceptions\CntrlException; use Respect\Validation\Exceptions\ControlException;
use Respect\Validation\Exceptions\NestedValidationException; use Respect\Validation\Exceptions\NestedValidationException;
use Respect\Validation\Validator as v; use Respect\Validation\Validator as v;
try { try {
v::cntrl()->check('16-50'); v::control()->check('16-50');
} catch (CntrlException $exception) { } catch (ControlException $exception) {
echo $exception->getMessage().PHP_EOL; echo $exception->getMessage().PHP_EOL;
} }
try { try {
v::cntrl('16')->check('16-50'); v::control('16')->check('16-50');
} catch (CntrlException $exception) { } catch (ControlException $exception) {
echo $exception->getMessage().PHP_EOL; echo $exception->getMessage().PHP_EOL;
} }
try { try {
v::not(v::cntrl())->check("\n"); v::not(v::control())->check("\n");
} catch (CntrlException $exception) { } catch (ControlException $exception) {
echo $exception->getMessage().PHP_EOL; echo $exception->getMessage().PHP_EOL;
} }
try { try {
v::not(v::cntrl('16'))->check("16\n"); v::not(v::control('16'))->check("16\n");
} catch (CntrlException $exception) { } catch (ControlException $exception) {
echo $exception->getMessage().PHP_EOL; echo $exception->getMessage().PHP_EOL;
} }
try { try {
v::cntrl()->assert('Foo'); v::control()->assert('Foo');
} catch (NestedValidationException $exception) { } catch (NestedValidationException $exception) {
echo $exception->getFullMessage().PHP_EOL; echo $exception->getFullMessage().PHP_EOL;
} }
try { try {
v::cntrl('Bar')->assert('Foo'); v::control('Bar')->assert('Foo');
} catch (NestedValidationException $exception) { } catch (NestedValidationException $exception) {
echo $exception->getFullMessage().PHP_EOL; echo $exception->getFullMessage().PHP_EOL;
} }
try { try {
v::not(v::cntrl())->assert("\n"); v::not(v::control())->assert("\n");
} catch (NestedValidationException $exception) { } catch (NestedValidationException $exception) {
echo $exception->getFullMessage().PHP_EOL; echo $exception->getFullMessage().PHP_EOL;
} }
try { try {
v::not(v::cntrl('Bar'))->assert("Bar\n"); v::not(v::control('Bar'))->assert("Bar\n");
} catch (NestedValidationException $exception) { } catch (NestedValidationException $exception) {
echo $exception->getFullMessage().PHP_EOL; echo $exception->getFullMessage().PHP_EOL;
} }

View file

@ -20,7 +20,7 @@ use stdClass;
* @group rule * @group rule
* *
* @covers \Respect\Validation\Rules\AbstractFilterRule * @covers \Respect\Validation\Rules\AbstractFilterRule
* @covers \Respect\Validation\Rules\Cntrl * @covers \Respect\Validation\Rules\Control
* *
* @author Andre Ramaciotti <andre@ramaciotti.com> * @author Andre Ramaciotti <andre@ramaciotti.com>
* @author Gabriel Caruso <carusogabriel34@gmail.com> * @author Gabriel Caruso <carusogabriel34@gmail.com>
@ -28,22 +28,22 @@ use stdClass;
* @author Nick Lombard <github@jigsoft.co.za> * @author Nick Lombard <github@jigsoft.co.za>
* @author Pascal Borreli <pascal@borreli.com> * @author Pascal Borreli <pascal@borreli.com>
*/ */
final class CntrlTest extends RuleTestCase final class ControlTest extends RuleTestCase
{ {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function providerForValidInput(): array public function providerForValidInput(): array
{ {
$cntrl = new Cntrl(); $sut = new Control();
return [ return [
'\n' => [$cntrl, "\n"], '\n' => [$sut, "\n"],
'\r' => [$cntrl, "\r"], '\r' => [$sut, "\r"],
'\t' => [$cntrl, "\t"], '\t' => [$sut, "\t"],
'\n\r\t' => [$cntrl, "\n\r\t"], '\n\r\t' => [$sut, "\n\r\t"],
'Ignoring all characters' => [new Cntrl('!@#$%^&*(){} '), '!@#$%^&*(){} '], 'Ignoring all characters' => [new Control('!@#$%^&*(){} '), '!@#$%^&*(){} '],
'Ignoring some characters' => [new Cntrl('[]?+=/\\-_|"\',<>. '), "[]?+=/\\-_|\"',<>. \t \n"], 'Ignoring some characters' => [new Control('[]?+=/\\-_|"\',<>. '), "[]?+=/\\-_|\"',<>. \t \n"],
]; ];
} }
@ -52,20 +52,20 @@ final class CntrlTest extends RuleTestCase
*/ */
public function providerForInvalidInput(): array public function providerForInvalidInput(): array
{ {
$cntrl = new Cntrl(); $sut = new Control();
return [ return [
'empty parameter' => [$cntrl, ''], 'empty parameter' => [$sut, ''],
'16-50' => [$cntrl, '16-50'], '16-50' => [$sut, '16-50'],
'a' => [$cntrl, 'a'], 'a' => [$sut, 'a'],
'white space' => [$cntrl, ' '], 'white space' => [$sut, ' '],
'Foo' => [$cntrl, 'Foo'], 'Foo' => [$sut, 'Foo'],
'12.1' => [$cntrl, '12.1'], '12.1' => [$sut, '12.1'],
'"-12"' => [$cntrl, '-12'], '"-12"' => [$sut, '-12'],
'-12' => [$cntrl, -12], '-12' => [$sut, -12],
'alganet' => [$cntrl, 'alganet'], 'alganet' => [$sut, 'alganet'],
'empty array parameter' => [$cntrl, []], 'empty array parameter' => [$sut, []],
'object' => [$cntrl, new stdClass()], 'object' => [$sut, new stdClass()],
]; ];
} }
} }