openvk/Web/Models/Repositories/CurrentUser.php

32 lines
615 B
PHP
Raw Normal View History

2023-08-02 16:56:07 +03:00
<?php declare(strict_types=1);
namespace openvk\Web\Models\Repositories;
use openvk\Web\Models\Entities\User;
class CurrentUser
{
private static $instance = null;
private $user;
public function __construct(?User $user = NULL)
{
if ($user)
$this->user = $user;
}
public static function get($user)
{
if (self::$instance === null) self::$instance = new self($user);
return self::$instance;
}
public function getUser(): User
{
return $this->user;
}
public static function i()
{
return self::$instance;
}
}