public function extractResult(Result $result)
 {
     $headings = $this->exportHeadings;
     $lead = $result->getLead();
     $entityManager = $this->getEntityManager();
     $hydrator = new DoctrineHydrator($entityManager);
     $leadArray = $hydrator->extract($lead);
     $output = array_combine($headings, array_pad([], count($headings), ""));
     foreach ($headings as $heading) {
         switch ($heading) {
             case "Score":
                 $score = $result->getScore();
                 $output[$heading] = $score ? $score : "N/A";
                 break;
             case "Account":
                 $account = $lead->getAccount();
                 $output[$heading] = $account ? $account->getName() : "N/A";
                 break;
             case "Last Submitted":
                 $time = $lead->getLastsubmitted();
                 if ($time instanceof \DateTime) {
                     $time = date_format($time, 'Y-m-d H:i:s');
                 }
                 $output[$heading] = $time;
                 break;
             case "Time Created":
                 $time = $lead->getTimecreated();
                 if ($time instanceof \DateTime) {
                     $time = date_format($time, 'Y-m-d H:i:s');
                 }
                 $output[$heading] = $time;
                 break;
             case "Referrer":
                 $output[$heading] = $lead->getReferrer();
                 break;
             case "IP Address":
                 $output[$heading] = $lead->getIpaddress();
                 break;
             default:
                 $attribute = $lead->findAttribute($heading);
                 if (!$attribute) {
                     $attributes = $lead->getAttributes(true)->filter(function ($attribute) use($heading) {
                         $real_attribute = false;
                         $attribute_desc = false;
                         if ($attribute) {
                             $real_attribute = $attribute->getAttribute();
                         }
                         if ($real_attribute) {
                             $attribute_desc = $real_attribute->getAttributeDesc();
                         }
                         return $attribute_desc == $heading;
                     });
                     if ($attributes->count() > 0) {
                         $attribute = $attributes->first();
                     }
                 }
                 if ($attribute) {
                     $output[$heading] = $attribute->getValue();
                 }
                 break;
         }
     }
     return $output;
 }