Extracts all the URLs and the indices they occur at from the tweet.
public extractURLsWithIndices ( ) : array | ||
리턴 | array | The URLs elements in the tweet. |
/** * Determines the length of a tweet. Takes shortening of URLs into account. * * @param string $tweet The tweet to validate. * @return int the length of a tweet. */ public function getTweetLength($tweet = null) { if (is_null($tweet)) { $tweet = $this->tweet; } $length = mb_strlen($tweet); $urls_with_indices = $this->extractor->extractURLsWithIndices($tweet); foreach ($urls_with_indices as $x) { $length += $x['indices'][0] - $x['indices'][1]; $length += stripos($x['url'], 'https://') === 0 ? $this->short_url_length_https : $this->short_url_length; } return $length; }