/**
  * @param AbstractSource $source
  * @return array
  */
 private function parseSource(AbstractSource $source)
 {
     $document = array('objectID' => sha1($source->sourceId()), 'title' => $source->data()->get('title'), 'body' => strip_tags($source->content()), 'url' => rtrim($source->permalink()->relativeUrlPath(), '/') . '/', 'date' => $source->data()->get('calculated_date'));
     $tags = is_array($source->data()->get('tags')) ? $source->data()->get('tags') : array();
     if ($tags) {
         $document['tags'] = $tags;
     }
     return $document;
 }
 /**
  * {@inheritDoc}
  */
 public function build(AbstractSource $source)
 {
     $sourceId = $source->sourceId();
     $tags = is_array($source->data()->get('tags')) ? $source->data()->get('tags') : array();
     $categories = is_array($source->data()->get('categories')) ? $source->data()->get('categories') : null;
     $record = array('objectID' => md5($sourceId), 'title' => $source->data()->get('title'), 'content' => strip_tags($source->content()), 'link' => $source->permalink()->relativeUrlPath(), 'date' => $source->data()->get('calculated_date'));
     // add em if we have em
     if ($categories != NULL) {
         $record["categories"] = $categories;
     }
     if ($tags != NULL) {
         $record["tags"] = $tags;
     }
     return $record;
 }