PHP Класс 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}.
Автор: Nick Pope ([email protected])
Наследование: extends Twitter_Regex
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
isValidMatch ( string $string, string $pattern, boolean $optional = false ) : boolean A helper function to check for a valid match. Used in URL validation.

Описание методов

__construct() публичный Метод

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

create() публичный статический Метод

Provides fluent method chaining.
См. также: __construct()
public static create ( string $tweet ) : Twitter_Validation
$tweet string The tweet to be validated.
Результат Twitter_Validation

getLength() публичный Метод

Determines the length of a tweet. Takes shortening of URLs into account.
public getLength ( ) : integer
Результат integer the length of a tweet.

isValidMatch() защищенный статический Метод

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.
Результат boolean Whether an exact match was found.

validateHashtag() публичный Метод

Check whether a hashtag is valid.
public validateHashtag ( ) : boolean
Результат boolean Whether the hashtag is valid.

validateList() публичный Метод

Check whether a list is valid.
public validateList ( ) : boolean
Результат boolean Whether the list is valid.

validateTweet() публичный Метод

Check whether a tweet is valid.
public validateTweet ( ) : boolean
Результат boolean Whether the tweet is valid.

validateURL() публичный Метод

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?
Результат boolean Whether the URL is valid.

validateUsername() публичный Метод

Check whether a username is valid.
public validateUsername ( ) : boolean
Результат boolean Whether the username is valid.