Example #1
0
 /**
  * Create a Topic Collection prepopulated with an array of data
  *
  * @param  array                    $topicArray
  * @throws InvalidArgumentException
  * @return \Klout\Collection\Topic
  */
 public static function createTopicCollection(array $topicArray)
 {
     $topics = new TopicCollection();
     if (empty($topicArray)) {
         return $topics;
     }
     foreach ($topicArray as $topicData) {
         $topic = new self($topicData);
         if (!$topic->getTopicId()) {
             throw new InvalidArgumentException('Invalid topic data.');
         }
         $topics[(string) $topic->getTopicId()] = $topic;
     }
     return $topics;
 }