Fix:2 for #97 Refactor rename Vowels to Vowel.

As per #97 Plural rules no singular.
Vowels to Vowel.
Vowelss now a deprecated decorator class of Vowel.
Documentation updated.
This commit is contained in:
nickl- 2013-01-22 23:53:27 +02:00
parent e82f209ffd
commit 2c9371e048
5 changed files with 42 additions and 19 deletions

View file

@ -229,7 +229,8 @@ Reference
* v::uppercase()
* v::uppercase()
* v::version()
* v::vowels()
* v::vowels() *(deprecated)*
* v::vowel()
* v::xdigits()
### Arrays
@ -342,7 +343,7 @@ See also:
* v::alpha() - a-Z, empty or whitespace only
* v::digit() - 0-9, empty or whitespace only
* v::consonant()
* v::vowels()
* v::vowel()
#### v::alpha()
#### v::alpha(string $additionalChars)
@ -356,7 +357,7 @@ See also:
* v::alnum() - a-z0-9, empty or whitespace only
* v::digit() - 0-9, empty or whitespace only
* v::consonant()
* v::vowels()
* v::vowel()
#### v::arr()
@ -539,7 +540,7 @@ See also:
* v::alnum() - a-z0-9, empty or whitespace only
* v::digit() - 0-9, empty or whitespace only
* v::alpha() - a-Z, empty or whitespace only
* v::vowels()
* v::vowel()
#### v::contains($value)
#### v::contains($value, boolean $identical=false)
@ -676,7 +677,7 @@ See also:
* v::alnum() - a-z0-9, empty or whitespace only
* v::alpha() - a-Z, empty or whitespace only
* v::vowels()
* v::vowel()
* v::consonant()
#### v::domain()
@ -1380,11 +1381,21 @@ Validates version numbers using Semantic Versioning.
v::version()->validate('1.0.0');
#### v::vowels()
#### v::vowels() *(deprecated)*
Similar to `v::alnum()`. Validates strings that contain only vowels:
Validates strings that contains only vowels. It's now deprecated, vowel should be used
instead.
v::vowels()->validate('aei'); //true
See also:
* v::vowel()
#### v::vowel()
Similar to `v::alnum()`. Validates strings that contains only vowels:
v::vowel()->validate('aei'); //true
See also:

View file

@ -1,7 +1,7 @@
<?php
namespace Respect\Validation\Exceptions;
class VowelsException extends AlphaException
class VowelException extends AlphaException
{
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(

View file

@ -0,0 +1,11 @@
<?php
namespace Respect\Validation\Rules;
class Vowel extends AbstractRegexRule
{
protected function getPregFormat()
{
return '/^(\s|[aeiouAEIOU])*$/';
}
}

View file

@ -1,11 +1,12 @@
<?php
namespace Respect\Validation\Rules;
class Vowels extends AbstractRegexRule
class Vowels extends Vowel
{
protected function getPregFormat()
public function __construct()
{
return '/^(\s|[aeiouAEIOU])*$/';
parent::__construct();
trigger_error("Use consonant instead.",
E_USER_DEPRECATED);
}
}

View file

@ -1,24 +1,24 @@
<?php
namespace Respect\Validation\Rules;
class VowelsTest extends \PHPUnit_Framework_TestCase
class VowelTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider providerForValidVowels
*/
public function testValidDataWithVowelsShouldReturnTrue($validVowels, $aditional='')
{
$validator = new Vowels($aditional);
$validator = new Vowel($aditional);
$this->assertTrue($validator->validate($validVowels));
}
/**
* @dataProvider providerForInvalidVowels
* @expectedException Respect\Validation\Exceptions\VowelsException
* @expectedException Respect\Validation\Exceptions\VowelException
*/
public function testInvalidVowelsShouldFailAndThrowVowelsException($invalidVowels, $aditional='')
public function testInvalidVowelsShouldFailAndThrowVowelException($invalidVowels, $aditional='')
{
$validator = new Vowels($aditional);
$validator = new Vowel($aditional);
$this->assertFalse($validator->validate($invalidVowels));
$this->assertFalse($validator->assert($invalidVowels));
}
@ -29,7 +29,7 @@ class VowelsTest extends \PHPUnit_Framework_TestCase
*/
public function testInvalidConstructorParamsShouldThrowComponentExceptionUponInstantiation($aditional)
{
$validator = new Vowels($aditional);
$validator = new Vowel($aditional);
}
public function providerForInvalidParams()