Pop\Feed\Reader::getByAccountId PHP Method

getByAccountId() public static method

Static method to create a Feed Reader object from an account ID
public static getByAccountId ( string $service, string $id, integer $limit, string $prefix = 'Pop\Feed\Format\' ) : Reader
$service string
$id string
$limit integer
$prefix string
return Reader
    public static function getByAccountId($service, $id, $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('id' => $id), $limit));
    }

Usage Example

Esempio n. 1
0
 public function testGetByAccountIdException()
 {
     $this->setExpectedException('Pop\\Feed\\Exception');
     $feed = Feed\Reader::getByAccountId('badservice', '1234567890', 4);
 }