2014-10-03 01:16:57 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 17:07:57 +02:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2015-03-26 11:44:34 +01:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2016-07-21 18:13:36 +02:00
|
|
|
* @author Robin Appelman <robin@icewind.nl>
|
2015-03-26 11:44:34 +01:00
|
|
|
*
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
2019-12-03 19:57:53 +01:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2015-03-26 11:44:34 +01:00
|
|
|
*
|
2014-10-03 01:16:57 +02:00
|
|
|
*/
|
2014-10-03 20:39:09 +02:00
|
|
|
namespace OC\Diagnostics;
|
2014-10-03 01:16:57 +02:00
|
|
|
|
2014-10-03 20:39:09 +02:00
|
|
|
use OCP\Diagnostics\IEvent;
|
2014-10-03 01:16:57 +02: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-03 22:13:55 +02:00
|
|
|
if (!$this->end) {
|
|
|
|
$this->end = microtime(true);
|
|
|
|
}
|
2014-10-03 01:16:57 +02:00
|
|
|
return $this->end - $this->start;
|
|
|
|
}
|
2022-02-02 09:57:50 +01:00
|
|
|
|
|
|
|
public function __toString() {
|
|
|
|
return $this->getId() . ' ' . $this->getDescription() . ' ' . $this->getDuration();
|
|
|
|
}
|
2014-10-03 01:16:57 +02:00
|
|
|
}
|