Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 99d4587b3b | |||
| 7f917ed0cb | |||
| c931c55478 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,4 +1,6 @@
|
|||||||
build
|
build
|
||||||
composer.lock
|
composer.lock
|
||||||
docs
|
docs
|
||||||
vendor
|
vendor
|
||||||
|
.php-cs-fixer.cache
|
||||||
|
.phpcs-cache
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "1sept/oauth2-vkontakte",
|
"name": "1sept/oauth2-vkontakte",
|
||||||
|
"version": "1.2",
|
||||||
"description": "VK provider for league/oauth2-client",
|
"description": "VK provider for league/oauth2-client",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"league",
|
"league",
|
||||||
@@ -13,7 +14,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php" : ">=8.1",
|
"php" : ">=8.3",
|
||||||
"league/oauth2-client": "^2.0"
|
"league/oauth2-client": "^2.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
|||||||
20
phpcs.xml.dist
Normal file
20
phpcs.xml.dist
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
|
||||||
|
|
||||||
|
<arg name="basepath" value="."/>
|
||||||
|
<arg name="cache" value=".phpcs-cache"/>
|
||||||
|
<arg name="colors"/>
|
||||||
|
<arg name="extensions" value="php"/>
|
||||||
|
|
||||||
|
<rule ref="PSR12">
|
||||||
|
<exclude name="Generic.Files.LineLength"/>
|
||||||
|
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<file>src/</file>
|
||||||
|
|
||||||
|
</ruleset>
|
||||||
|
|
||||||
|
<!-- composer require "squizlabs/php_codesniffer=*" dev -->
|
||||||
14
phpstan.dist.neon
Normal file
14
phpstan.dist.neon
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
parameters:
|
||||||
|
level: 5
|
||||||
|
paths:
|
||||||
|
- bin/
|
||||||
|
- config/
|
||||||
|
- public/
|
||||||
|
- src/
|
||||||
|
|
||||||
|
errorFormat: table
|
||||||
|
editorUrl: 'vscode://file/%%file%%:%%line%%'
|
||||||
|
editorUrlTitle: '%%relFile%%:%%line%%'
|
||||||
|
|
||||||
|
ignoreErrors:
|
||||||
|
- '#Construct empty\(\) is not allowed. Use more strict comparison.#'
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Sept\OAuth2\Client\Provider;
|
namespace Sept\OAuth2\Client\Provider;
|
||||||
|
|
||||||
use League\OAuth2\Client\Provider\AbstractProvider;
|
use League\OAuth2\Client\Provider\AbstractProvider;
|
||||||
@@ -9,10 +11,10 @@ use Psr\Http\Message\ResponseInterface;
|
|||||||
|
|
||||||
class VkProvider extends AbstractProvider
|
class VkProvider extends AbstractProvider
|
||||||
{
|
{
|
||||||
protected $baseOAuthUri = 'https://oauth.vk.com';
|
protected string $baseOAuthUri = 'https://oauth.vk.com';
|
||||||
protected $baseUri = 'https://api.vk.com/method';
|
protected string $baseUri = 'https://api.vk.com/method';
|
||||||
protected $version = '5.236';
|
protected float $version = 5.199;
|
||||||
protected $language = null;
|
protected ?string $language = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see https://vk.com/dev/permissions
|
* @see https://vk.com/dev/permissions
|
||||||
@@ -21,26 +23,26 @@ class VkProvider extends AbstractProvider
|
|||||||
'email',
|
'email',
|
||||||
// 'friends',
|
// 'friends',
|
||||||
// 'offline',
|
// 'offline',
|
||||||
//'photos',
|
// 'photos',
|
||||||
//'wall',
|
// 'wall',
|
||||||
//'ads',
|
// 'ads',
|
||||||
//'audio',
|
// 'audio',
|
||||||
//'docs',
|
// 'docs',
|
||||||
//'groups',
|
// 'groups',
|
||||||
//'market',
|
// 'market',
|
||||||
//'messages',
|
// 'messages',
|
||||||
//'nohttps',
|
// 'nohttps',
|
||||||
//'notes',
|
// 'notes',
|
||||||
//'notifications',
|
// 'notifications',
|
||||||
//'notify',
|
// 'notify',
|
||||||
//'pages',
|
// 'pages',
|
||||||
//'stats',
|
// 'stats',
|
||||||
//'status',
|
// 'status',
|
||||||
//'video',
|
// 'video',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type array
|
* @see https://new.vk.com/dev/fields
|
||||||
* @see https://new.vk.com/dev/fields
|
|
||||||
*/
|
*/
|
||||||
public array $userFields = [
|
public array $userFields = [
|
||||||
'bdate',
|
'bdate',
|
||||||
@@ -60,63 +62,62 @@ class VkProvider extends AbstractProvider
|
|||||||
'photo_max_orig',
|
'photo_max_orig',
|
||||||
'screen_name',
|
'screen_name',
|
||||||
'sex',
|
'sex',
|
||||||
//'about',
|
'deactivated',
|
||||||
//'activities',
|
'is_closed',
|
||||||
//'blacklisted',
|
// 'about',
|
||||||
//'blacklisted_by_me',
|
// 'activities',
|
||||||
//'books',
|
// 'blacklisted',
|
||||||
//'can_post',
|
// 'blacklisted_by_me',
|
||||||
//'can_see_all_posts',
|
// 'books',
|
||||||
//'can_see_audio',
|
// 'can_post',
|
||||||
//'can_send_friend_request',
|
// 'can_see_all_posts',
|
||||||
//'can_write_private_message',
|
// 'can_see_audio',
|
||||||
//'career',
|
// 'can_send_friend_request',
|
||||||
//'common_count',
|
// 'can_write_private_message',
|
||||||
//'connections',
|
// 'career',
|
||||||
//'contacts',
|
// 'common_count',
|
||||||
//'crop_photo',
|
// 'connections',
|
||||||
//'counters',
|
// 'contacts',
|
||||||
//'deactivated',
|
// 'crop_photo',
|
||||||
//'education',
|
// 'counters',
|
||||||
//'exports',
|
// 'deactivated',
|
||||||
//'followers_count',
|
// 'education',
|
||||||
//'games',
|
// 'exports',
|
||||||
//'has_mobile',
|
// 'followers_count',
|
||||||
//'hidden',
|
// 'games',
|
||||||
//'interests',
|
// 'has_mobile',
|
||||||
//'is_favorite',
|
// 'hidden',
|
||||||
//'is_hidden_from_feed',
|
// 'interests',
|
||||||
//'last_seen',
|
// 'is_favorite',
|
||||||
//'military',
|
// 'is_hidden_from_feed',
|
||||||
//'movies',
|
// 'last_seen',
|
||||||
//'occupation',
|
// 'military',
|
||||||
//'online',
|
// 'movies',
|
||||||
//'personal',
|
// 'occupation',
|
||||||
//'photo_100',
|
// 'online',
|
||||||
//'photo_200',
|
// 'personal',
|
||||||
//'photo_200_orig',
|
// 'photo_100',
|
||||||
//'photo_400_orig',
|
// 'photo_200',
|
||||||
//'photo_50',
|
// 'photo_200_orig',
|
||||||
//'photo_id',
|
// 'photo_400_orig',
|
||||||
//'quotes',
|
// 'photo_50',
|
||||||
//'relation',
|
// 'photo_id',
|
||||||
//'relatives',
|
// 'quotes',
|
||||||
//'schools',
|
// 'relation',
|
||||||
//'site',
|
// 'relatives',
|
||||||
//'status',
|
// 'schools',
|
||||||
//'timezone',
|
// 'site',
|
||||||
//'tv',
|
// 'status',
|
||||||
//'universities',
|
// 'timezone',
|
||||||
//'verified',
|
// 'tv',
|
||||||
//'wall_comments',
|
// 'universities',
|
||||||
|
// 'verified',
|
||||||
|
// 'wall_comments',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $language
|
|
||||||
*/
|
|
||||||
public function setLanguage(string $language): self
|
public function setLanguage(string $language): self
|
||||||
{
|
{
|
||||||
$this->language = (string)$language;
|
$this->language = $language;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -130,24 +131,26 @@ class VkProvider extends AbstractProvider
|
|||||||
{
|
{
|
||||||
return "$this->baseOAuthUri/access_token";
|
return "$this->baseOAuthUri/access_token";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getResourceOwnerDetailsUrl(AccessToken $token): string
|
public function getResourceOwnerDetailsUrl(AccessToken $token): string
|
||||||
{
|
{
|
||||||
$params = [
|
$params = [
|
||||||
'fields' => $this->userFields,
|
'fields' => $this->userFields,
|
||||||
'access_token' => $token->getToken(),
|
'access_token' => $token->getToken(),
|
||||||
'v' => $this->version,
|
'v' => $this->version,
|
||||||
'lang' => $this->language
|
'lang' => $this->language,
|
||||||
];
|
];
|
||||||
$query = $this->buildQueryString($params);
|
$query = $this->buildQueryString($params);
|
||||||
$url = "$this->baseUri/users.get?$query";
|
$url = "$this->baseUri/users.get?$query";
|
||||||
|
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
protected function getDefaultScopes()
|
|
||||||
|
protected function getDefaultScopes(): array
|
||||||
{
|
{
|
||||||
return $this->scopes;
|
return $this->scopes;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function checkResponse(ResponseInterface $response, $data): void
|
protected function checkResponse(ResponseInterface $response, $data): void
|
||||||
{
|
{
|
||||||
// Metadata info
|
// Metadata info
|
||||||
@@ -155,14 +158,15 @@ class VkProvider extends AbstractProvider
|
|||||||
$contentTypeArray = explode(';', reset($contentTypeRaw));
|
$contentTypeArray = explode(';', reset($contentTypeRaw));
|
||||||
$contentType = reset($contentTypeArray);
|
$contentType = reset($contentTypeArray);
|
||||||
// Response info
|
// Response info
|
||||||
$responseCode = $response->getStatusCode();
|
$responseCode = $response->getStatusCode();
|
||||||
$responseMessage = $response->getReasonPhrase();
|
$responseMessage = $response->getReasonPhrase();
|
||||||
|
|
||||||
// Data info
|
// Data info
|
||||||
$error = !empty($data['error']) ? $data['error'] : null;
|
$error = !empty($data['error']) ? $data['error'] : null;
|
||||||
$errorCode = !empty($error['error_code']) ? $error['error_code'] : $responseCode;
|
$errorCode = !empty($error['error_code']) ? $error['error_code'] : $responseCode;
|
||||||
$errorDescription = !empty($data['error_description']) ? $data['error_description'] : null;
|
$errorDescription = !empty($data['error_description']) ? $data['error_description'] : null;
|
||||||
$errorMessage = !empty($error['error_msg']) ? $error['error_msg'] : $errorDescription;
|
$errorMessage = !empty($error['error_msg']) ? $error['error_msg'] : $errorDescription;
|
||||||
$message = $errorMessage ?: $responseMessage;
|
$message = (bool) $errorMessage ? $errorMessage : $responseMessage;
|
||||||
|
|
||||||
// Request/meta validation
|
// Request/meta validation
|
||||||
if (399 < $responseCode) {
|
if (399 < $responseCode) {
|
||||||
@@ -170,89 +174,93 @@ class VkProvider extends AbstractProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Content validation
|
// Content validation
|
||||||
if ('application/json' != $contentType) {
|
if ('application/json' !== $contentType) {
|
||||||
throw new IdentityProviderException($message, $responseCode, $data);
|
throw new IdentityProviderException($message, $responseCode, $data);
|
||||||
}
|
}
|
||||||
if ($error) {
|
if ($error) {
|
||||||
throw new IdentityProviderException($errorMessage, $errorCode, $data);
|
throw new IdentityProviderException($errorMessage, $errorCode, $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createResourceOwner(array $response, AccessToken $token): VkUser
|
protected function createResourceOwner(array $response, AccessToken $token): VkUser
|
||||||
{
|
{
|
||||||
$response = reset($response['response']);
|
$response = reset($response['response']);
|
||||||
$additional = $token->getValues();
|
$additional = $token->getValues();
|
||||||
|
|
||||||
if (!empty($additional['email'])) {
|
if (!empty($additional['email'])) {
|
||||||
$response['email'] = $additional['email'];
|
$response['email'] = $additional['email'];
|
||||||
}
|
}
|
||||||
if (!empty($response['uid']) && 4 === floor($this->version)) {
|
|
||||||
|
if (!empty($response['uid']) && 4 === (int) floor($this->version)) {
|
||||||
$response['id'] = $response['uid'];
|
$response['id'] = $response['uid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($additional['user_id'])) {
|
if (!empty($additional['user_id'])) {
|
||||||
$response['id'] = $additional['user_id'];
|
$response['id'] = $additional['user_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return new VkUser($response, $response['id']);
|
return new VkUser($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Возвращает массив объектов пользователей.
|
||||||
|
*
|
||||||
* @see https://vk.com/dev/users.get
|
* @see https://vk.com/dev/users.get
|
||||||
*
|
|
||||||
* @param integer[] $ids
|
|
||||||
* @param AccessToken|null $token Current user if empty
|
|
||||||
* @param array $params
|
|
||||||
*
|
|
||||||
* @return User[]
|
|
||||||
*/
|
*/
|
||||||
public function usersGet(array $ids = [], AccessToken $token = null, array $params = []): array
|
public function usersGet(array $ids = [], ?AccessToken $token = null, array $params = []): array
|
||||||
{
|
{
|
||||||
if (empty($ids) && !$token) {
|
if (empty($ids) && null === $token) {
|
||||||
throw new \InvalidArgumentException('Some of parameters usersIds OR access_token are required');
|
throw new \InvalidArgumentException('Some of parameters usersIds OR access_token are required');
|
||||||
}
|
}
|
||||||
|
|
||||||
$default = [
|
$default = [
|
||||||
'user_ids' => implode(',', $ids),
|
'user_ids' => implode(',', $ids),
|
||||||
'fields' => $this->userFields,
|
'fields' => $this->userFields,
|
||||||
'access_token' => $token ? $token->getToken() : null,
|
'access_token' => null !== $token ? $token->getToken() : null,
|
||||||
'v' => $this->version,
|
'v' => $this->version,
|
||||||
'lang' => $this->language
|
'lang' => $this->language,
|
||||||
];
|
];
|
||||||
$params = array_merge($default, $params);
|
|
||||||
$query = $this->buildQueryString($params);
|
|
||||||
$url = "$this->baseUri/users.get?$query";
|
|
||||||
|
|
||||||
$response = $this->getResponse($this->createRequest(static::METHOD_GET, $url, $token, []))['response'];
|
$params = array_merge($default, $params);
|
||||||
$users = !empty($response['items']) ? $response['items'] : $response;
|
$query = $this->buildQueryString($params);
|
||||||
$array2user = function ($userData) {
|
$url = "$this->baseUri/users.get?$query";
|
||||||
|
|
||||||
|
$response = $this->getResponse($this->createRequest(static::METHOD_GET, $url, $token, []))['response'];
|
||||||
|
$users = !empty($response['items']) ? $response['items'] : $response;
|
||||||
|
|
||||||
|
$array2user = function (mixed $userData) {
|
||||||
return new VkUser($userData);
|
return new VkUser($userData);
|
||||||
};
|
};
|
||||||
|
|
||||||
return array_map($array2user, $users);
|
return array_map($array2user, $users);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Возвращает список идентификаторов (id) друзей пользователя,
|
||||||
|
* если параметр fields не использовался. При использовании
|
||||||
|
* параметра fields возвращает список объектов пользователей,
|
||||||
|
* но не более 5000.
|
||||||
|
*
|
||||||
* @see https://vk.com/dev/friends.get
|
* @see https://vk.com/dev/friends.get
|
||||||
*
|
|
||||||
* @param integer $userId
|
|
||||||
* @param AccessToken|null $token
|
|
||||||
* @param array $params
|
|
||||||
*
|
|
||||||
* @return User[]
|
|
||||||
*/
|
*/
|
||||||
public function friendsGet($userId, AccessToken $token = null, array $params = []): array
|
public function friendsGet(int $userId, ?AccessToken $token = null, array $params = []): array
|
||||||
{
|
{
|
||||||
$default = [
|
$default = [
|
||||||
'user_id' => $userId,
|
'user_id' => $userId,
|
||||||
'fields' => $this->userFields,
|
'fields' => $this->userFields,
|
||||||
'access_token' => $token ? $token->getToken() : null,
|
'access_token' => null !== $token ? $token->getToken() : null,
|
||||||
'v' => $this->version,
|
'v' => $this->version,
|
||||||
'lang' => $this->language
|
'lang' => $this->language,
|
||||||
];
|
];
|
||||||
$params = array_merge($default, $params);
|
|
||||||
$query = $this->buildQueryString($params);
|
|
||||||
$url = "$this->baseUri/friends.get?$query";
|
|
||||||
|
|
||||||
$response = $this->getResponse($this->createRequest(static::METHOD_GET, $url, $token, []))['response'];
|
$params = array_merge($default, $params);
|
||||||
$friends = !empty($response['items']) ? $response['items'] : $response;
|
$query = $this->buildQueryString($params);
|
||||||
$array2friend = function ($friendData) {
|
$url = "$this->baseUri/friends.get?$query";
|
||||||
|
|
||||||
|
$response = $this->getResponse($this->createRequest(static::METHOD_GET, $url, $token, []))['response'];
|
||||||
|
$friends = !empty($response['items']) ? $response['items'] : $response;
|
||||||
|
|
||||||
|
$array2friend = function (mixed $friendData) {
|
||||||
if (is_numeric($friendData)) {
|
if (is_numeric($friendData)) {
|
||||||
$friendData = ['id' => $friendData];
|
$friendData = ['id' => $friendData];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Sept\OAuth2\Client\Provider;
|
namespace Sept\OAuth2\Client\Provider;
|
||||||
|
|
||||||
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
|
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see https://vk.com/dev/fields
|
* @see https://vk.com/dev/fields
|
||||||
*/
|
*/
|
||||||
class VkUser implements ResourceOwnerInterface
|
class VkUser implements ResourceOwnerInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @type array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $response;
|
protected $response;
|
||||||
|
|
||||||
@@ -21,29 +23,29 @@ class VkUser implements ResourceOwnerInterface
|
|||||||
{
|
{
|
||||||
$this->response = $response;
|
$this->response = $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
return $this->response;
|
return $this->response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): int
|
public function getId(): int
|
||||||
{
|
{
|
||||||
return (int)($this->getField('uid') ?: $this->getField('id'));
|
return (int) ((bool) $this->getField('uid') ? $this->getField('uid') : $this->getField('id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper for getting user data
|
* Helper for getting user data.
|
||||||
*/
|
*/
|
||||||
protected function getField(string $key): mixed
|
protected function getField(string $key): mixed
|
||||||
{
|
{
|
||||||
return !empty($this->response[$key]) ? $this->response[$key] : null;
|
return \array_key_exists($key, $this->response) ? $this->response[$key] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string|null DD.MM.YYYY
|
* @return string|null DD.MM.YYYY
|
||||||
*/
|
*/
|
||||||
public function getBirthday():string
|
public function getBirthday(): ?string
|
||||||
{
|
{
|
||||||
return $this->getField('bdate');
|
return $this->getField('bdate');
|
||||||
}
|
}
|
||||||
@@ -51,36 +53,41 @@ class VkUser implements ResourceOwnerInterface
|
|||||||
/**
|
/**
|
||||||
* @return array [id =>, title => string]
|
* @return array [id =>, title => string]
|
||||||
*/
|
*/
|
||||||
public function getCity(): array
|
public function getCity(): ?array
|
||||||
{
|
{
|
||||||
return $this->getField('city');
|
return $this->getField('city');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array [id =>, title => string]
|
* @return array [id =>, title => string]
|
||||||
*/
|
*/
|
||||||
public function getCountry(): array
|
public function getCountry(): ?array
|
||||||
{
|
{
|
||||||
return $this->getField('country');
|
return $this->getField('country');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short address to user page
|
* Short address to user page.
|
||||||
*/
|
*/
|
||||||
public function getDomain(): string
|
public function getDomain(): ?string
|
||||||
{
|
{
|
||||||
return $this->getField('domain');
|
return $this->getField('domain');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFirstName(): string
|
/**
|
||||||
|
* Return firstname.
|
||||||
|
*/
|
||||||
|
public function getFirstName(): ?string
|
||||||
{
|
{
|
||||||
return $this->getField('first_name');
|
return $this->getField('first_name');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Friend status.
|
||||||
|
*
|
||||||
* @return int 0|1|2|3 => nobody|resquest_sent|incoming_request|friends
|
* @return int 0|1|2|3 => nobody|resquest_sent|incoming_request|friends
|
||||||
*/
|
*/
|
||||||
public function getFriendStatus(): int
|
public function getFriendStatus(): ?int
|
||||||
{
|
{
|
||||||
return $this->getField('friend_Status');
|
return $this->getField('friend_Status');
|
||||||
}
|
}
|
||||||
@@ -90,61 +97,80 @@ class VkUser implements ResourceOwnerInterface
|
|||||||
*/
|
*/
|
||||||
public function isHasPhoto(): bool
|
public function isHasPhoto(): bool
|
||||||
{
|
{
|
||||||
return (bool)$this->getField('has_photo');
|
return (bool) $this->getField('has_photo');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHomeTown(): string
|
public function getHomeTown(): ?string
|
||||||
{
|
{
|
||||||
return $this->getField('home_town');
|
return $this->getField('home_town');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect if current user is freind to this
|
* Detect if current user is freind to this.
|
||||||
*/
|
*/
|
||||||
public function isFriend(): bool
|
public function isFriend(): bool
|
||||||
{
|
{
|
||||||
return (bool)$this->getField('is_friend');
|
return (bool) $this->getField('is_friend');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastName(): string
|
public function getLastName(): ?string
|
||||||
{
|
{
|
||||||
return $this->getField('last_name');
|
return $this->getField('last_name');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMaidenName(): string
|
public function getMaidenName(): ?string
|
||||||
{
|
{
|
||||||
return $this->getField('maiden_name');
|
return $this->getField('maiden_name');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNickname(): string
|
public function getNickname(): ?string
|
||||||
{
|
{
|
||||||
return $this->getField('nickname');
|
return $this->getField('nickname');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It's square!
|
* It's square!
|
||||||
*/
|
*/
|
||||||
public function getPhotoMax():string
|
public function getPhotoMax(): ?string
|
||||||
{
|
{
|
||||||
return $this->getField('photo_max');
|
return $this->getField('photo_max');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPhotoMaxOrig(): string
|
public function getPhotoMaxOrig(): ?string
|
||||||
{
|
{
|
||||||
return $this->getField('photo_max_orig');
|
return $this->getField('photo_max_orig');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getScreenName(): string
|
public function getScreenName(): ?string
|
||||||
{
|
{
|
||||||
return $this->getField('screen_name');
|
return $this->getField('screen_name');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSex(): int
|
public function getSex(): ?int
|
||||||
{
|
{
|
||||||
return $this->getField('sex');
|
return $this->getField('sex');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmail(): string
|
public function getEmail(): ?string
|
||||||
{
|
{
|
||||||
return $this->getField('email');
|
return $this->getField('email');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Поле возвращается, если страница пользователя удалена или заблокирована, содержит значение deleted или banned. В этом случае опциональные поля не возвращаются.
|
||||||
|
*
|
||||||
|
* @return string null|deleted|banned
|
||||||
|
*/
|
||||||
|
public function getDeactivated(): ?string
|
||||||
|
{
|
||||||
|
return $this->getField('deactivated');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Скрыт ли профиль пользователя настройками приватности.
|
||||||
|
*/
|
||||||
|
public function isClosed(): bool
|
||||||
|
{
|
||||||
|
return $this->getField('is_closed');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user