Пример #1
0
 /**
  * @param Vampire $vampire
  */
 public function addVampire(Vampire $vampire)
 {
     $position = FilePosition::createPosition($vampire->getFile(), $vampire->getLine());
     $logDate = strtotime($vampire->getInvocationDate());
     if (!isset($this->vampires[$position]) || $logDate > $this->maxDatePerPosition[$position]) {
         $this->vampires[$position] = $vampire;
         $this->maxDatePerPosition[$position] = $logDate;
     }
 }
Пример #2
0
 /**
  * @param Vampire $vampire
  *
  * @return string
  */
 public static function vampireToLog(Vampire $vampire)
 {
     return json_encode(array('v' => self::CURRENT_VERSION, 'd' => $vampire->getTombstoneDate(), 'a' => $vampire->getAuthor(), 'l' => $vampire->getLabel(), 'f' => $vampire->getFile(), 'n' => $vampire->getLine(), 'm' => $vampire->getMethod(), 'id' => $vampire->getInvocationDate(), 'im' => $vampire->getInvoker()));
 }
Пример #3
0
 /**
  * Formats a Vampire for the log
  *
  * @param Vampire $vampire
  *
  * @return string
  */
 public function format(Vampire $vampire)
 {
     return json_encode(array('tombstoneDate' => $vampire->getTombstoneDate(), 'author' => $vampire->getAuthor(), 'label' => $vampire->getLabel(), 'file' => $vampire->getFile(), 'line' => $vampire->getLine(), 'method' => $vampire->getMethod(), 'invocationDate' => $vampire->getInvocationDate(), 'invoker' => $vampire->getInvoker())) . "\n";
 }
Пример #4
0
 /**
  * Formats a Vampire for the log
  *
  * @param Vampire $vampire
  *
  * @return string
  */
 public function format(Vampire $vampire)
 {
     $template = '%s - Vampire detected: tombstone("%s", "%s"%s), in file %s:%s, in function %s, invoked by %s' . "\n";
     return sprintf($template, $vampire->getInvocationDate(), $vampire->getTombstoneDate(), $vampire->getAuthor(), $vampire->getLabel() ? ', "' . $vampire->getLabel() . '"' : '', $vampire->getFile(), $vampire->getLine(), $vampire->getMethod(), $vampire->getInvoker());
 }