2014-10-03 03:16:57 +04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
2014-10-03 22:39:09 +04:00
|
|
|
namespace OC\Diagnostics;
|
2014-10-03 03:16:57 +04:00
|
|
|
|
2014-10-03 22:39:09 +04:00
|
|
|
use OCP\Diagnostics\IEvent;
|
2014-10-03 03:16:57 +04:00
|
|
|
|
|
|
|
class Event implements IEvent {
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var float
|
|
|
|
*/
|
|
|
|
protected $start;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var float
|
|
|
|
*/
|
|
|
|
protected $end;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $id
|
|
|
|
* @param string $description
|
|
|
|
* @param float $start
|
|
|
|
*/
|
|
|
|
public function __construct($id, $description, $start) {
|
|
|
|
$this->id = $id;
|
|
|
|
$this->description = $description;
|
|
|
|
$this->start = $start;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param float $time
|
|
|
|
*/
|
|
|
|
public function end($time) {
|
|
|
|
$this->end = $time;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return float
|
|
|
|
*/
|
|
|
|
public function getStart() {
|
|
|
|
return $this->start;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getId() {
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getDescription() {
|
|
|
|
return $this->description;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return float
|
|
|
|
*/
|
|
|
|
public function getEnd() {
|
|
|
|
return $this->end;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return float
|
|
|
|
*/
|
|
|
|
public function getDuration() {
|
2014-10-04 00:13:55 +04:00
|
|
|
if (!$this->end) {
|
|
|
|
$this->end = microtime(true);
|
|
|
|
}
|
2014-10-03 03:16:57 +04:00
|
|
|
return $this->end - $this->start;
|
|
|
|
}
|
|
|
|
}
|