2016-11-27 03:13:42 +05:30
|
|
|
<?php
|
2019-08-23 13:58:04 +05:30
|
|
|
declare(strict_types=1);
|
2016-11-27 03:13:42 +05:30
|
|
|
|
2024-12-06 06:04:09 +05:30
|
|
|
namespace common\components\OAuth2\Entities;
|
2016-11-27 03:13:42 +05:30
|
|
|
|
2024-12-08 21:24:45 +05:30
|
|
|
use common\models\OauthClient;
|
2019-08-23 13:58:04 +05:30
|
|
|
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
|
|
|
use League\OAuth2\Server\Entities\Traits\ClientTrait;
|
|
|
|
use League\OAuth2\Server\Entities\Traits\EntityTrait;
|
2016-12-18 04:50:53 +05:30
|
|
|
|
2024-12-06 06:04:09 +05:30
|
|
|
final class ClientEntity implements ClientEntityInterface {
|
2019-08-23 13:58:04 +05:30
|
|
|
use EntityTrait;
|
|
|
|
use ClientTrait;
|
2016-11-27 03:13:42 +05:30
|
|
|
|
2019-09-22 02:47:21 +05:30
|
|
|
/**
|
2024-12-06 06:04:09 +05:30
|
|
|
* @phpstan-param non-empty-string $id
|
|
|
|
* @phpstan-param string|list<string> $redirectUri
|
2019-09-22 02:47:21 +05:30
|
|
|
*/
|
2024-12-02 15:40:55 +05:30
|
|
|
public function __construct(
|
|
|
|
string $id,
|
|
|
|
string $name,
|
|
|
|
string|array $redirectUri,
|
|
|
|
private readonly bool $isTrusted,
|
|
|
|
) {
|
2019-08-23 13:58:04 +05:30
|
|
|
$this->identifier = $id;
|
2016-11-27 03:13:42 +05:30
|
|
|
$this->name = $name;
|
|
|
|
$this->redirectUri = $redirectUri;
|
2019-09-22 02:47:21 +05:30
|
|
|
}
|
|
|
|
|
2024-12-08 21:24:45 +05:30
|
|
|
public static function fromModel(OauthClient $model): self {
|
|
|
|
return new self(
|
|
|
|
$model->id, // @phpstan-ignore argument.type
|
|
|
|
$model->name,
|
|
|
|
$model->redirect_uri ?: '',
|
|
|
|
(bool)$model->is_trusted,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-09-22 02:47:21 +05:30
|
|
|
public function isConfidential(): bool {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isTrusted(): bool {
|
|
|
|
return $this->isTrusted;
|
2016-12-18 04:50:53 +05:30
|
|
|
}
|
|
|
|
|
2016-11-27 03:13:42 +05:30
|
|
|
}
|