PHP Class Twitter_Validation, twitter-text-php

Performs "validation" on tweets. Originally written by {@link http://github.com/mikenz Mike Cochrane}, this is based on code by {@link http://github.com/mzsanford Matt Sanford} and heavily modified by {@link http://github.com/ngnpope Nick Pope}.
Author: Nick Pope ([email protected])
Inheritance: extends Twitter_Regex
Mostrar archivo Open project: ngnpope/twitter-text-php Class Usage Examples

Public Methods

Method Description
__construct ( string $tweet ) Reads in a tweet to be parsed and validates it.
create ( string $tweet ) : Twitter_Validation Provides fluent method chaining.
getLength ( ) : integer Determines the length of a tweet. Takes shortening of URLs into account.
validateHashtag ( ) : boolean Check whether a hashtag is valid.
validateList ( ) : boolean Check whether a list is valid.
validateTweet ( ) : boolean Check whether a tweet is valid.
validateURL ( boolean $unicode_domains = true, boolean $require_protocol = true ) : boolean Check whether a URL is valid.
validateUsername ( ) : boolean Check whether a username is valid.

Protected Methods

Method Description
isValidMatch ( string $string, string $pattern, boolean $optional = false ) : boolean A helper function to check for a valid match. Used in URL validation.

Method Details

__construct() public method

Reads in a tweet to be parsed and validates it.
public __construct ( string $tweet )
$tweet string The tweet to validate.

create() public static method

Provides fluent method chaining.
See also: __construct()
public static create ( string $tweet ) : Twitter_Validation
$tweet string The tweet to be validated.
return Twitter_Validation

getLength() public method

Determines the length of a tweet. Takes shortening of URLs into account.
public getLength ( ) : integer
return integer the length of a tweet.

isValidMatch() protected static method

A helper function to check for a valid match. Used in URL validation.
protected static isValidMatch ( string $string, string $pattern, boolean $optional = false ) : boolean
$string string The subject string to test.
$pattern string The pattern to match against.
$optional boolean Whether a match is compulsory or not.
return boolean Whether an exact match was found.

validateHashtag() public method

Check whether a hashtag is valid.
public validateHashtag ( ) : boolean
return boolean Whether the hashtag is valid.

validateList() public method

Check whether a list is valid.
public validateList ( ) : boolean
return boolean Whether the list is valid.

validateTweet() public method

Check whether a tweet is valid.
public validateTweet ( ) : boolean
return boolean Whether the tweet is valid.

validateURL() public method

Check whether a URL is valid.
public validateURL ( boolean $unicode_domains = true, boolean $require_protocol = true ) : boolean
$unicode_domains boolean Consider the domain to be unicode.
$require_protocol boolean Require a protocol for valid domain?
return boolean Whether the URL is valid.

validateUsername() public method

Check whether a username is valid.
public validateUsername ( ) : boolean
return boolean Whether the username is valid.