Merge branch 'marcelo-develop' into develop

This commit is contained in:
Alexandre Gomes Gaigalas 2011-04-04 16:03:47 -03:00
commit 182425ee0a
4 changed files with 29 additions and 25 deletions

View file

@ -46,12 +46,14 @@ abstract class AbstractComposite extends AbstractRule implements Validatable
{
if (empty($this->rules))
return false;
elseif ($validator instanceof Valitatable)
if ($validator instanceof Valitatable)
return isset($this->rules[spl_object_hash($validator)]);
else
foreach ($this->rules as $rule)
if ($rule instanceof $validator)
return true;
foreach ($this->rules as $rule)
if ($rule instanceof $validator)
return true;
return false;
}
@ -106,4 +108,4 @@ abstract class AbstractComposite extends AbstractRule implements Validatable
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
*/

View file

@ -18,24 +18,24 @@ class Contains extends AbstractRule
{
if ($this->identical)
return $this->validateIdentical($input);
else
return $this->validateEquals($input);
return $this->validateEquals($input);
}
protected function validateEquals($input)
{
if (is_array($input))
return in_array($this->containsValue, $input);
else
return false !== mb_stripos($input, $this->containsValue);
return false !== mb_stripos($input, $this->containsValue);
}
protected function validateIdentical($input)
{
if (is_array($input))
return in_array($this->containsValue, $input, true);
else
return false !== mb_strpos($input, $this->containsValue);
return false !== mb_strpos($input, $this->containsValue);
}
}
@ -71,4 +71,4 @@ class Contains extends AbstractRule
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
*/

View file

@ -23,12 +23,14 @@ class In extends AbstractRule
{
if (is_array($this->haystack))
return in_array($input, $this->haystack, $this->compareIdentical);
elseif (!is_string($this->haystack))
if (!is_string($this->haystack))
return false;
elseif ($this->compareIdentical)
if ($this->compareIdentical)
return mb_strpos($this->haystack, $input) !== false;
else
return mb_stripos($this->haystack, $input) !== false;
return mb_stripos($this->haystack, $input) !== false;
}
}
@ -64,4 +66,4 @@ class In extends AbstractRule
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
*/

View file

@ -18,24 +18,24 @@ class StartsWith extends AbstractRule
{
if ($this->identical)
return $this->validateIdentical($input);
else
return $this->validateEquals($input);
return $this->validateEquals($input);
}
protected function validateEquals($input)
{
if (is_array($input))
return reset($input) == $this->startValue;
else
return 0 === mb_stripos($input, $this->startValue);
return 0 === mb_stripos($input, $this->startValue);
}
protected function validateIdentical($input)
{
if (is_array($input))
return reset($input) === $this->startValue;
else
return 0 === mb_strpos($input, $this->startValue);
return 0 === mb_strpos($input, $this->startValue);
}
}
@ -71,4 +71,4 @@ class StartsWith extends AbstractRule
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
*/