Public Member Functions | Protected Attributes

Robo47_Filter_UrlScheme Class Reference

List of all members.

Public Member Functions

 __construct (array $options=array())
 filter ($value)
 Filter.
 getDefaultScheme ()
 Get default Scheme.
 getSchemes ()
 Get Schemes.
 getTrim ()
 Get Trim.
 setDefaultScheme ($defaultScheme)
 Set default Scheme.
 setOptions ($options)
 Set Options.
 setSchemes (array $schemes)
 Set Schemes.
 setTrim ($flag=true)
 Set Trim.

Protected Attributes

 $_defaultScheme = 'http'
 $_schemes
 $_trim = true

Detailed Description

Definition at line 33 of file UrlScheme.php.


Constructor & Destructor Documentation

Robo47_Filter_UrlScheme::__construct ( array $  options = array()  ) 
Parameters:
string $defaultScheme

Definition at line 61 of file UrlScheme.php.

References setOptions().

    {
        $this->setOptions($options);
    }

Here is the call graph for this function:


Member Function Documentation

Robo47_Filter_UrlScheme::filter ( value  ) 

Filter.

Parameters:
string $value
Returns:
string

Definition at line 163 of file UrlScheme.php.

References getDefaultScheme(), getSchemes(), and getTrim().

    {
        if ($this->getTrim()) {
            $value = trim($value);
        }
        if (empty($value)) {
            return '';
        }
        $schemeFound = false;
        $schemes = $this->getSchemes();
        foreach ($schemes as $scheme) {
            if (0 === strpos($value, $scheme . '://')) {
                $schemeFound = true;
            }
        }
        if (!$schemeFound) {
            $value = $this->getDefaultScheme() .
                '://' . $value;
        }
        return $value;
    }

Here is the call graph for this function:

Robo47_Filter_UrlScheme::getDefaultScheme (  ) 

Get default Scheme.

Returns:
string

Definition at line 130 of file UrlScheme.php.

Referenced by filter().

    {
        return $this->_defaultScheme;
    }

Here is the caller graph for this function:

Robo47_Filter_UrlScheme::getSchemes (  ) 

Get Schemes.

Returns:
array

Definition at line 109 of file UrlScheme.php.

Referenced by filter().

    {
        return $this->_schemes;
    }

Here is the caller graph for this function:

Robo47_Filter_UrlScheme::getTrim (  ) 

Get Trim.

Returns:
bool

Definition at line 152 of file UrlScheme.php.

Referenced by filter().

    {
        return $this->_trim;
    }

Here is the caller graph for this function:

Robo47_Filter_UrlScheme::setDefaultScheme ( defaultScheme  ) 

Set default Scheme.

Parameters:
string $defaultScheme
Returns:
Robo47_Filter_UrlScheme *Provides Fluent Interface*

Definition at line 119 of file UrlScheme.php.

Referenced by setOptions().

    {
        $this->_defaultScheme = $defaultScheme;
        return $this;
    }

Here is the caller graph for this function:

Robo47_Filter_UrlScheme::setOptions ( options  ) 

Set Options.

Parameters:
array|Zend_Config $options
Returns:
Robo47_Filter_UrlScheme *Provides Fluent Interface*

Definition at line 72 of file UrlScheme.php.

References setDefaultScheme(), setSchemes(), and setTrim().

Referenced by __construct().

    {
        foreach ($options as $key => $value) {
            switch ($key) {
                case 'trim':
                    $this->setTrim($value);
                    break;
                case 'defaultScheme':
                    $this->setDefaultScheme($value);
                    break;
                case 'schemes':
                    $this->setSchemes($value);
                    break;
                default:
                    break;
            }
        }
        return $this;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Robo47_Filter_UrlScheme::setSchemes ( array $  schemes  ) 

Set Schemes.

Parameters:
array $schemes
Returns:
Robo47_Filter_UrlScheme *Provides Fluent Interface*

Definition at line 98 of file UrlScheme.php.

Referenced by setOptions().

    {
        $this->_schemes = $schemes;
        return $this;
    }

Here is the caller graph for this function:

Robo47_Filter_UrlScheme::setTrim ( flag = true  ) 

Set Trim.

Parameters:
bool $flag
Returns:
Robo47_Filter_UrlScheme *Provides Fluent Interface*

Definition at line 141 of file UrlScheme.php.

Referenced by setOptions().

    {
        $this->_trim = (bool) $flag;
        return $this;
    }

Here is the caller graph for this function:


Member Data Documentation

Robo47_Filter_UrlScheme::$_defaultScheme = 'http' [protected]

Definition at line 50 of file UrlScheme.php.

Robo47_Filter_UrlScheme::$_schemes [protected]
Initial value:
 array(
        'http',
        'https',
        'ftp',
        'ftps'
    )

Definition at line 40 of file UrlScheme.php.

Robo47_Filter_UrlScheme::$_trim = true [protected]

Definition at line 55 of file UrlScheme.php.


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