Revert "[WIP] Add Utils.resolveScreenName (#884)" (#885)

This reverts commit 051fb316a4.
This commit is contained in:
Vladimir Barinov 2023-06-03 11:14:39 +03:00 committed by GitHub
parent 051fb316a4
commit 8c1a680f84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,39 +1,10 @@
<?php declare(strict_types=1);
namespace openvk\VKAPI\Handlers;
use openvk\Web\Models\Entities\Alias;
use openvk\Web\Models\Repositories\Aliases;
final class Utils extends VKAPIRequestHandler
{
function getServerTime(): int
{
return time();
}
function resolveScreenName(string $screen_name): object
{
if(\Chandler\MVC\Routing\Router::i()->getMatchingRoute("/$screen_name")[0]->presenter !== "UnknownTextRouteStrategy") {
if(substr($screen_name, 0, strlen("id")) === "id") {
return (object) [
"object_id" => (int) substr($screen_name, strlen("id")),
"type" => "user"
];
} else if(substr($screen_name, 0, strlen("club")) === "club") {
return (object) [
"object_id" => (int) substr($screen_name, strlen("club")),
"type" => "group"
];
}
} else {
$alias = (new Aliases)->getByShortCode($screen_name);
if(!$alias) return (object)[];
return (object) [
"object_id" => $alias->getOwnerId(),
"type" => $alias->getType()
];
}
}
}