/** * @param Reader $reader */ public function __construct(Reader $reader) { $tweets = []; foreach ($reader->fetchAssoc() as $tweet) { $tweets[] = new Tweet($this->getFrom($tweet, 'tweet_id'), $this->getFrom($tweet, 'text'), $this->getFrom($tweet, 'source'), $this->getFrom($tweet, 'timestamp'), $this->getFrom($tweet, 'in_reply_to_status_id'), $this->getFrom($tweet, 'retweeted_status_id'), $this->getFrom($tweet, 'expanded_urls')); } $this->tweetCollection = new TweetCollection($tweets); }
/** * Set the metadata from a file. * * @param string $file */ public function setDefaultsFromFile($file) { $file = new Reader($file); // Fetch columns $rows = $file->fetchOne(); $file->setOffset(1); // Fetch entries and set defaults $entries = $file->fetchAssoc($rows); foreach ($entries as $entry) { if (strpos(URL::current(), $entry['url']) !== false) { $this->defaults = $entry; } } }
/** * Return raw data * * @return Iterator */ public function getData() { return $this->reader->fetchAssoc(); }