Public Member Functions | Public Attributes | Protected Attributes

Robo47_Validate_StringContains Class Reference

Inheritance diagram for Robo47_Validate_StringContains:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 __construct ($contains)
 getContains ()
 Get Contains.
 isValid ($value)
 Is Valid.
 setContains ($contains)
 Set Contains.

Public Attributes

const CONTAINS = 'contains'

Protected Attributes

 $_contains = ''
 $_messageTemplates
 $_messageVariables

Detailed Description

Definition at line 31 of file StringContains.php.


Constructor & Destructor Documentation

Robo47_Validate_StringContains::__construct ( contains  ) 
Parameters:
string|array $contains

Definition at line 50 of file StringContains.php.

References setContains().

    {
        $this->setContains($contains);
    }

Here is the call graph for this function:


Member Function Documentation

Robo47_Validate_StringContains::getContains (  ) 

Get Contains.

Returns:
array

Definition at line 79 of file StringContains.php.

    {
        return $this->_contains;
    }

Robo47_Validate_StringContains::isValid ( value  ) 

Is Valid.

Returns:
bool

Reimplemented in Robo47_Validate_StringNotContains.

Definition at line 89 of file StringContains.php.

    {
        $this->_setValue($value);

        $isValid = false;
        foreach ($this->_contains as $contains) {
            if (false !== strpos($value, $contains)) {
                $isValid = true;
                $this->_error(self::CONTAINS);
                break;
            }
        }
        return $isValid;
    }

Robo47_Validate_StringContains::setContains ( contains  ) 

Set Contains.

Parameters:
string|array $contains
Returns:
Robo47_Validate_StringContains *Provides Fluent Interface*

Definition at line 61 of file StringContains.php.

Referenced by __construct().

    {
        if (is_string($contains)) {
            $contains = array($contains);
        }
        if (empty($contains)) {
            $message = '$contains is empty';
            throw new Robo47_Validate_Exception($message);
        }
        $this->_contains = $contains;
        return $this;
    }

Here is the caller graph for this function:


Member Data Documentation

Robo47_Validate_StringContains::$_contains = '' [protected]

Definition at line 38 of file StringContains.php.

Robo47_Validate_StringContains::$_messageTemplates [protected]
Initial value:
 array(
        self::CONTAINS =>
        "'%value%' does not contain any of the specified strings",
    )

Reimplemented in Robo47_Validate_StringNotContains.

Definition at line 39 of file StringContains.php.

Robo47_Validate_StringContains::$_messageVariables [protected]
Initial value:
 array(
        'value' => '_value',
    )

Definition at line 43 of file StringContains.php.

Definition at line 33 of file StringContains.php.


The documentation for this class was generated from the following file: