2023-01-05 03:20:31 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu\Twitter;
|
|
|
|
|
|
|
|
use Stringable;
|
|
|
|
use Misuzu\Config\IConfig;
|
|
|
|
|
|
|
|
class TwitterClientId implements Stringable {
|
|
|
|
public function __construct(
|
|
|
|
private string $clientId,
|
|
|
|
private string $clientSecret
|
|
|
|
) {}
|
|
|
|
|
|
|
|
public function hasClientId(): bool {
|
|
|
|
return $this->clientId !== '' && $this->clientSecret !== '';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getClientId(): string {
|
|
|
|
return $this->clientId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getClientSecret(): string {
|
|
|
|
return $this->clientSecret;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __toString(): string {
|
|
|
|
return 'Basic ' . base64_encode($this->clientId . ':' . $this->clientSecret);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function load(IConfig $config): self {
|
|
|
|
return new static(
|
2023-01-06 20:50:41 +00:00
|
|
|
$config->getValue('clientId', IConfig::T_STR),
|
|
|
|
$config->getValue('clientSecret', IConfig::T_STR)
|
2023-01-05 03:20:31 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|