protected function getDateOfBirth(Lead $lead)
 {
     $DateOfBirth = null;
     $match = $lead->findAttribute('birth', true);
     if ($match) {
         $date = $match->getValue();
         $DateOfBirth = $date instanceof \DateTime ? date_format('m/d/Y', $date) : (Helper::validateDate($date) ? date('m/d/Y', strtotime($date)) : null);
     }
     return $DateOfBirth;
 }
 public function format_value($value, $type = null)
 {
     $formatted = null;
     if (!$type) {
         $attribute = $this->getAttribute();
         if (isset($attribute)) {
             $type = $attribute->getAttributeType() ?: 'string';
         }
     }
     switch ($type) {
         case 'date':
             $date = str_replace('-', '/', $this->value);
             if (count(explode('/', $date)) > 1) {
                 $ts = strtotime($date);
                 if (date('Y', $ts) > date('Y')) {
                     $darray = [];
                     $darray[] = date('m', $ts);
                     $darray[] = date('d', $ts);
                     $darray[] = date('Y', $ts) - 100;
                     $date = implode('/', $darray);
                 }
                 if (Helper::validateDate($date)) {
                     $formatted = new \DateTime(date('Y-m-d', strtotime($date)));
                 }
             }
             break;
         case 'number':
             $limits = ['upper' => pow(2, 31) - 1, 'lower' => -1 * (pow(2, 31) - 1)];
             if (preg_match('/([\\d\\.]+)/i', $value, $match)) {
                 $number = isset($match[1]) ? $match[1] : null;
                 if (!$number || !is_numeric($number)) {
                     $formatted = null;
                 } else {
                     $float = floatval($number);
                     $formatted = $float > $limits['upper'] || $float < $limits['lower'] ? null : $float;
                 }
             }
             break;
         default:
             $formatted = $value;
             break;
     }
     return $formatted;
 }