/**
  * Command start time (without microseconds)
  * @return \DateTime
  */
 protected function getStartTime()
 {
     $date = \DateTime::createFromFormat('U', (int) ($this->stopWatchEvent->getOrigin() / 1000));
     if (!$date) {
         $this->logger->debug('getStartTime error', array('tag' => 'UNABLE_TO_CREATE_DATETIME', 'origin' => $this->stopWatchEvent->getOrigin(), 'originType' => gettype($this->stopWatchEvent->getOrigin())));
     }
     return $date;
 }
 /**
  * Set ending time of the call and write log.
  *
  * @param StopwatchEvent $event
  * @param string         $resource
  */
 public function logCallDuration(StopwatchEvent $event, $resource)
 {
     if (static::IS_LOG_ACTIVE) {
         $filePath = $this->logDir . static::LOG_FILE_NAME;
         $duration = $event->getDuration() / 1000;
         $duration = number_format($duration, 3);
         $startTime = ($event->getOrigin() + $event->getStartTime()) / 1000;
         $callStart = date(static::DATE_FORMAT, (int) $startTime);
         $this->writeLog($filePath, $callStart, $resource, $duration);
     }
 }
 public function testGetOrigin()
 {
     $event = new StopwatchEvent(12);
     $this->assertEquals(12, $event->getOrigin());
 }