vendor/codeages/biz-framework/src/Context/CurrentUser.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Codeages\Biz\Framework\Context;
/**
* 当前系统中的登录用户
*/
class CurrentUser implements \ArrayAccess
{
/**
* Data
*
* @var array
*/
private $user = array();
public function __construct(array $user)
{
$this->requireds($user, array('id', 'username', 'login_client', 'login_ip'));
$this->user = $user;
}
public function offsetSet($key, $value)
{
if (empty($key)) {
throw new \InvalidArgumentException('Key is empty, set current user attribute failed.');
}
if (array_key_exists($key, $this->user)) {
throw new \LogicException('Key is already exist, set current user attribute failed.');
}
$this->user[$key] = $value;
}
public function offsetUnset($key)
{
throw new \LogicException('can not unset current user attribute.');
}
public function offsetExists($key)
{
return array_key_exists($key, $this->user);
}
public function offsetGet($key)
{
if (!$this->offsetExists($key)) {
throw new \LogicException("Current user not have `{$key}` attribute.");
}
return $this->user[$key];
}
public function toArray()
{
return $this->user;
}
protected function requireds($user, $keys)
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。