mirror of
https://github.com/openvk/openvk
synced 2024-12-24 01:21:07 +03:00
Users: getByShortURL improvements
This commit is contained in:
parent
7557d6779b
commit
57d4f9da2d
1 changed files with 4 additions and 3 deletions
|
@ -30,14 +30,15 @@ class Users
|
||||||
|
|
||||||
function getByShortURL(string $url, bool $handleId = false): ?User
|
function getByShortURL(string $url, bool $handleId = false): ?User
|
||||||
{
|
{
|
||||||
$user = $this->toUser($this->users->where("shortcode", $url)->fetch());
|
$user = $this->toUser((clone $this->users)->where("shortcode", $url)->fetch());
|
||||||
if($user)
|
if($user !== null)
|
||||||
return $user;
|
return $user;
|
||||||
else if ($handleId == true)
|
else if ($handleId == true)
|
||||||
{
|
{
|
||||||
$id = array();
|
$id = array();
|
||||||
preg_match("/id([0-9]+)/", $url, $id);
|
preg_match("/id([0-9]+)/", $url, $id);
|
||||||
return $this->toUser($this->users->get($id[1]));
|
$id = intval($id[1]);
|
||||||
|
return $this->get($id);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue