Files
kiri-wchat/wchat/common/AppConfig.php
T
2023-11-13 23:52:41 +08:00

65 lines
1.1 KiB
PHP

<?php
namespace wchat\common;
use JetBrains\PhpStorm\ArrayShape;
class AppConfig
{
/**
* @var string
*/
protected string $appId = '';
/**
* @var string
*/
protected string $appSecret = '';
/**
* @var PayConfig
*/
protected PayConfig $payConfig;
/**
* @var int
*/
protected int $type;
/**
* @var array|string[]
*/
#[ArrayShape(['token' => 'string', 'secret' => 'string', 'unionId' => 'string'])]
protected array $notice = ['token' => '', 'secret' => '', 'unionId' => ''];
/**
* @param object $app
* @return static
*/
public static function instance(object $app): static
{
$model = new static();
$model->appId = $app->appId;
$model->appSecret = $app->appSecret;
$model->type = $app->type;
$model->payConfig = PayConfig::parse($app->pay);
return $model;
}
/**
* @return bool
*/
public function typeIsApp(): bool
{
return $this->type === 3;
}
}