/**
  * @param Vampire $vampire
  * @param TombstoneIndex $tombstoneIndex
  *
  * @return Tombstone|null
  */
 public function matchVampireToTombstone(Vampire $vampire, TombstoneIndex $tombstoneIndex)
 {
     if ($matchingTombstones = $tombstoneIndex->getInMethod($vampire->getMethod())) {
         foreach ($matchingTombstones as $matchingTombstone) {
             if ($vampire->inscriptionEquals($matchingTombstone)) {
                 return $matchingTombstone;
             }
         }
     }
     return null;
 }
예제 #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());
 }