Pop\Feed\Reader::getByAccountName PHP Method

getByAccountName() public static method

Static method to create a Feed Reader object from an account name
public static getByAccountName ( string $service, string $name, integer $limit, string $prefix = 'Pop\Feed\Format\' ) : Reader
$service string
$name string
$limit integer
$prefix string
return Reader
    public static function getByAccountName($service, $name, $limit = 0, $prefix = 'Pop\\Feed\\Format\\')
    {
        $formats = array('Atom', 'Json', 'Php', 'Rss');
        $service = ucfirst(strtolower($service));
        $class = null;
        foreach ($formats as $format) {
            if (class_exists($prefix . $format . '\\' . $service)) {
                $class = $prefix . $format . '\\' . $service;
            }
        }
        if (null === $class) {
            throw new Exception('Error: The class for that service feed could not be found.');
        }
        return new self(new $class(array('name' => $name), $limit));
    }

Usage Example

Esempio n. 1
0
 public function testGetByAccountNameException()
 {
     $this->setExpectedException('Pop\\Feed\\Exception');
     $feed = Feed\Reader::getByAccountName('badservice', '1234567890', 4);
 }
All Usage Examples Of Pop\Feed\Reader::getByAccountName