style:类型约束

This commit is contained in:
zyimm 2023-07-09 18:54:29 +08:00
parent 6853fd6699
commit f915a23bbd
2 changed files with 14 additions and 18 deletions

View File

@ -1,8 +1,9 @@
<?php
return [
'host' => env('mq_host', 'http://192.168.21.170:8085'),
'callback' => '/rocketmq/producer/notify',
'subscribe' => [
'host' => env('mq_host', 'http://192.168.21.170:8085'),
'callback_host' => env('mq_callback_host', 'http://192.168.21.170:8085'),
'callback' => '/rocketmq/producer/notify',
'subscribe' => [
]
];

View File

@ -12,9 +12,9 @@ class Config
public function __construct(array $configs = [])
{
foreach ($configs as $key => $val){
if(method_exists($key, $this)){
call_user_func([$this, $key], $val);
foreach ($configs as $key => $val) {
if (method_exists($key, $this)) {
call_user_func([$this, $key], $val);
}
}
}
@ -28,36 +28,31 @@ class Config
}
/**
* @param mixed $host
* @param string $host
*/
public function setHost($host): void
public function setHost(string $host): void
{
$this->host = $host;
}
/**
* @return mixed
* @return int
*/
public function getTimeOut()
{
return $this->timeOut;
return $this->timeOut ?? 60;
}
/**
* @param mixed $timeOut
* @param int $timeOut
*/
public function setTimeOut($timeOut): void
public function setTimeOut(int $timeOut): void
{
$this->timeOut = $timeOut;
}
public function getProducerUrl(): string
{
return $this->getHost().'notifyUsing';
}
public function getBackUrl(): string
{
return $this->getHost().config('rocket_mq.callback');
return config('rocket_mq.callback_host').config('rocket_mq.callback');
}
}