1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-12-04 07:27:50 +01:00
MadelineProto/src/Ipc/IpcState.php

74 lines
2.0 KiB
PHP
Raw Normal View History

2023-08-13 11:40:35 +02:00
<?php declare(strict_types=1);
2022-12-30 21:54:44 +01:00
2023-08-13 11:40:35 +02:00
/**
* This file is part of MadelineProto.
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* MadelineProto 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 General Public License along with MadelineProto.
* If not, see <http://www.gnu.org/licenses/>.
*
* @author Daniil Gentili <daniil@daniil.it>
* @copyright 2016-2023 Daniil Gentili <daniil@daniil.it>
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
* @link https://docs.madelineproto.xyz MadelineProto documentation
*/
2020-09-24 11:45:20 +02:00
namespace danog\MadelineProto\Ipc;
2022-12-30 19:21:36 +01:00
use Throwable;
2020-09-24 11:45:20 +02:00
/**
* IPC state class.
2023-02-16 18:38:47 +01:00
*
* @internal
2020-09-24 11:45:20 +02:00
*/
final class IpcState
{
/**
* Startup time.
*/
private float $startupTime;
/**
* Startup ID.
*/
private int $startupId;
/**
* Exception.
*/
2020-09-27 19:36:17 +02:00
private ?ExitFailure $exception;
2020-09-24 11:45:20 +02:00
/**
* Construct.
*/
2023-01-04 15:13:55 +01:00
public function __construct(int $startupId, ?Throwable $exception = null)
2020-09-24 11:45:20 +02:00
{
2023-10-01 20:05:04 +02:00
$this->startupTime = microtime(true);
2020-09-24 11:45:20 +02:00
$this->startupId = $startupId;
2020-09-27 19:36:17 +02:00
$this->exception = $exception ? new ExitFailure($exception) : null;
2020-09-24 11:45:20 +02:00
}
/**
* Get startup time.
*/
public function getStartupTime(): float
{
return $this->startupTime;
}
/**
* Get startup ID.
*/
public function getStartupId(): int
{
return $this->startupId;
}
/**
* Get exception.
*/
2022-12-30 19:21:36 +01:00
public function getException(): ?Throwable
2020-09-24 11:45:20 +02:00
{
2020-09-27 19:36:17 +02:00
return $this->exception ? $this->exception->getException() : null;
2020-09-24 11:45:20 +02:00
}
}