Public Member Functions | Public Attributes | Protected Attributes

Robo47_Validate_MaxLineLength Class Reference

List of all members.

Public Member Functions

 __construct ($lineLength=80, $encoding= 'utf-8')
 getEncoding ()
 Get Encoding.
 getLineLength ()
 Get LineLength.
 isValid ($value)
 Is Valid.
 setEncoding ($encoding)
 Set Encoding.
 setLineLength ($lineLength)
 Set LineLength.

Public Attributes

const LINE_TOO_LONG = 'lineToLong'
 Line too long.

Protected Attributes

 $_encoding = 'utf-8'
 $_lineLength = 80
 $_messageTemplates

Detailed Description

Definition at line 31 of file MaxLineLength.php.


Constructor & Destructor Documentation

Robo47_Validate_MaxLineLength::__construct ( lineLength = 80,
encoding = 'utf-8' 
)
Parameters:
integer $lineLength
string $encoding

Definition at line 58 of file MaxLineLength.php.

References setEncoding(), and setLineLength().

    {
        $this->setLineLength($lineLength);
        $this->setEncoding($encoding);
    }

Here is the call graph for this function:


Member Function Documentation

Robo47_Validate_MaxLineLength::getEncoding (  ) 

Get Encoding.

Returns:
string

Definition at line 81 of file MaxLineLength.php.

    {
        return $this->_encoding;
    }

Robo47_Validate_MaxLineLength::getLineLength (  ) 

Get LineLength.

Returns:
integer

Definition at line 109 of file MaxLineLength.php.

    {
        return $this->_lineLength;
    }

Robo47_Validate_MaxLineLength::isValid ( value  ) 

Is Valid.

See also:
Zend_Validate_Interface::isValid
Parameters:
mixed $value
Returns:
boolean

Definition at line 121 of file MaxLineLength.php.

    {
        // replace other line-endings
        $value = str_replace("\n\r", "\n", $value);
        $value = str_replace("\r\n", "\n", $value);
        // create array
        $asArray = explode("\n", $value);

        foreach ($asArray as $linenumber => $line) {
            if (mb_strwidth($line, $this->_encoding) > $this->_lineLength) {
                $this->_error(self::LINE_TOO_LONG, $linenumber + 1);
                return false;
            }
        }
        return true;
    }

Robo47_Validate_MaxLineLength::setEncoding ( encoding  ) 

Set Encoding.

Parameters:
string $encoding
Returns:
Robo47_Validate_LineLength *Provides Fluent Interface*

Definition at line 70 of file MaxLineLength.php.

Referenced by __construct().

    {
        $this->_encoding = $encoding;
        return $this;
    }

Here is the caller graph for this function:

Robo47_Validate_MaxLineLength::setLineLength ( lineLength  ) 

Set LineLength.

Parameters:
integer $lineLength
Returns:
Robo47_Validate_LineLength *Provides Fluent Interface*

Definition at line 92 of file MaxLineLength.php.

Referenced by __construct().

    {
        $lineLength = (int) $lineLength;
        if ($lineLength < 1) {
            $message = 'lineLength is less than 1';
            throw new Robo47_Validate_Exception($message);
        } else {
            $this->_lineLength = $lineLength;
        }
        return $this;
    }

Here is the caller graph for this function:


Member Data Documentation

Robo47_Validate_MaxLineLength::$_encoding = 'utf-8' [protected]

Definition at line 52 of file MaxLineLength.php.

Robo47_Validate_MaxLineLength::$_lineLength = 80 [protected]

Definition at line 46 of file MaxLineLength.php.

Robo47_Validate_MaxLineLength::$_messageTemplates [protected]
Initial value:
 array(
        self::LINE_TOO_LONG => "Line %value% is too long"
    )

Definition at line 38 of file MaxLineLength.php.

Line too long.

Definition at line 36 of file MaxLineLength.php.


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