/**
  * Process labels for adding into the issues table
  *
  * @param   integer  $issueId  Issue ID to process
  *
  * @return  string
  *
  * @since   1.0
  */
 protected function processLabels($issueId)
 {
     try {
         $githubLabels = $this->github->issues->get($this->project->gh_user, $this->project->gh_project, $issueId)->labels;
     } catch (\DomainException $exception) {
         $this->logger->error(sprintf('Error parsing the labels for GitHub issue %s/%s #%d - %s', $this->project->gh_user, $this->project->gh_project, $issueId, $exception->getMessage()));
         return '';
     }
     $appLabelIds = array();
     // Make sure the label is present in the database by pulling the ID, add it if it isn't
     $query = $this->db->getQuery(true);
     foreach ($githubLabels as $label) {
         $query->clear()->select($this->db->quoteName('label_id'))->from($this->db->quoteName('#__tracker_labels'))->where($this->db->quoteName('project_id') . ' = ' . (int) $this->project->project_id)->where($this->db->quoteName('name') . ' = ' . $this->db->quote($label->name));
         $this->db->setQuery($query);
         $id = $this->db->loadResult();
         // If null, add the label
         if ($id === null) {
             $table = new LabelsTable($this->db);
             $data = array();
             $data['project_id'] = $this->project->project_id;
             $data['name'] = $label->name;
             $data['color'] = $label->color;
             try {
                 $table->save($data);
                 $id = $table->label_id;
             } catch (\RuntimeException $exception) {
                 $this->logger->error(sprintf('Error adding label %s for project %s/%s to the database: %s', $label->name, $this->project->gh_user, $this->project->gh_project, $exception->getMessage()));
             }
         }
         // Add the ID to the array
         $appLabelIds[] = $id;
     }
     // Return the array as a string
     if (count($appLabelIds) === 0) {
         return '';
     } else {
         return implode(',', $appLabelIds);
     }
 }