public function testSetAndGetValue()
 {
     $this->assertEquals(null, $this->object->getValue());
     $val = 'new ret val';
     $this->object->setValue($val);
     $this->assertEquals($val, $this->object->getValue());
 }
 /**
  * @param Event $event
  * @return mixed
  */
 public function map($event)
 {
     if (!$event instanceof \GoogleAnalyticsTracker\HitTypes\Event) {
         throw new \UnexpectedValueException("The Event Mapper only accepts Event HitTypes");
     }
     $data = array('t' => \GoogleAnalyticsTracker\HitTypes\Event::TYPE, 'ea' => $event->getAction(), 'ec' => $event->getCategory());
     if ($event->hasLabel()) {
         $data['el'] = $event->getLabel();
     }
     if ($event->hasValue()) {
         $data['ev'] = $event->getValue();
     }
     $data = array_merge($data, parent::map($event));
     return $data;
 }
Example #3
0
 /**
  * Static method to Compare two events by their type
  *
  * @param Event $a
  * @param Event $b
  * @return int
  */
 static function CompareType(&$a, &$b)
 {
     global $factsort;
     if (empty($factsort)) {
         $factsort = array_flip(array("BIRT", "_HNM", "ALIA", "_AKA", "_AKAN", "ADOP", "_ADPF", "_ADPF", "_BRTM", "CHR", "BAPM", "FCOM", "CONF", "BARM", "BASM", "EDUC", "GRAD", "_DEG", "EMIG", "IMMI", "NATU", "_MILI", "_MILT", "ENGA", "MARB", "MARC", "MARL", "_MARI", "_MBON", "MARR", "MARR_CIVIL", "MARR_RELIGIOUS", "MARR_PARTNERS", "MARR_UNKNOWN", "_COML", "_STAT", "_SEPR", "DIVF", "MARS", "_BIRT_CHIL", "DIV", "ANUL", "_BIRT_", "_MARR_", "_DEAT_", "_BURI_", "CENS", "OCCU", "RESI", "PROP", "CHRA", "RETI", "FACT", "EVEN", "_NMR", "_NMAR", "NMR", "NCHI", "WILL", "_HOL", "_????_", "DEAT", "CAUS", "_FNRL", "BURI", "CREM", "_INTE", "CEME", "_YART", "_NLIV", "PROB", "TITL", "COMM", "NATI", "CITN", "CAST", "RELI", "SSN", "IDNO", "TEMP", "SLGC", "BAPL", "CONL", "ENDL", "SLGS", "AFN", "REFN", "_PRMN", "REF", "RIN", "ADDR", "PHON", "EMAIL", "_EMAIL", "EMAL", "FAX", "WWW", "URL", "_URL", "CHAN", "_TODO"));
     }
     // Facts from same families stay grouped together
     // Keep MARR and DIV from the same families from mixing with events from other FAMs
     // Use the original order in which the facts were added
     if ($a->getFamilyId() && $b->getFamilyId() && $a->getFamilyId() != $b->getFamilyId()) {
         return $a->sortOrder - $b->sortOrder;
     }
     $atag = $a->getTag();
     $btag = $b->getTag();
     // Events not in the above list get mapped onto one that is.
     if (!array_key_exists($atag, $factsort)) {
         if (preg_match('/^(_(BIRT|MARR|DEAT|BURI)_)/', $atag, $match)) {
             $atag = $match[1];
         } else {
             $atag = "_????_";
         }
     }
     if (!array_key_exists($btag, $factsort)) {
         if (preg_match('/^(_(BIRT|MARR|DEAT|BURI)_)/', $btag, $match)) {
             $btag = $match[1];
         } else {
             $btag = "_????_";
         }
     }
     //-- don't let dated after DEAT/BURI facts sort non-dated facts before DEAT/BURI
     //-- treat dated after BURI facts as BURI instead
     if ($a->getValue('DATE') != NULL && $factsort[$atag] > $factsort['BURI'] && $factsort[$atag] < $factsort['CHAN']) {
         $atag = 'BURI';
     }
     if ($b->getValue('DATE') != NULL && $factsort[$btag] > $factsort['BURI'] && $factsort[$btag] < $factsort['CHAN']) {
         $btag = 'BURI';
     }
     $ret = $factsort[$atag] - $factsort[$btag];
     //-- if facts are the same then put dated facts before non-dated facts
     if ($ret == 0) {
         if ($a->getValue('DATE') != NULL && $b->getValue('DATE') == NULL) {
             return -1;
         }
         if ($b->getValue('DATE') != NULL && $a->getValue('DATE') == NULL) {
             return 1;
         }
         //-- if no sorting preference, then keep original ordering
         $ret = $a->sortOrder - $b->sortOrder;
     }
     return $ret;
 }