src/Twitter.php
protected function queryToMeta($query)
    {
        $query = str_replace(' ', '+', $query);

        if (preg_match('~^(?:hashtag:|#)(\w+)$~i', $query, $matches)) {

            $type = 'hashtag';
            $url  = 'https://twitter.com/hashtag/' . $matches[1] . '?f=tweets';

        } elseif (preg_match('~^(?:user:|@)(\w+)$~i', $query, $matches)) {

            $type = 'user';
            $url  = 'https://twitter.com/' . $matches[1];

        } elseif (preg_match('~^(?:search:)(.+)$~i', $query, $matches)) {

            $type = 'search';
            $url  = 'https://twitter.com/search?f=tweets&q=' . $matches[1];

        } else {

            $type = 'search';
            $url  = 'https://twitter.com/search?f=tweets&q=' . $query;
        }

        return [ 'query' => $query, 'type' => $type, 'url' => $url ];
    }
protected function queryToMeta($query)
    {
        $query = str_replace(' ', '+', $query);

        if (preg_match('~^(?:hashtag:|#)(\w+)$~i', $query, $matches)) {

            $type = 'hashtag';
            $url  = 'https://twitter.com/hashtag/' . $matches[1] . '?f=tweets';

        } elseif (preg_match('~^(?:user:|@)(\w+)$~i', $query, $matches)) {

            $type = 'user';
            $url  = 'https://twitter.com/' . $matches[1];

        } elseif (preg_match('~^(?:search:)(.+)$~i', $query, $matches)) {

            $type = 'search';
            $url  = 'https://twitter.com/search?f=tweets&q=' . $matches[1];

        } else {

            $type = 'search';
            $url  = 'https://twitter.com/search?f=tweets&q=' . $query;
        }

        return [ 'query' => $query, 'type' => $type, 'url' => $url ];
    }
Convert a query to an associative array of metadata.

@see doc/Twitter.md

@param string $query

@return array with the following structure:
(array)
type  (string) hashtag, search or user
url   (string) URL of the target page
query (string)