Skip to content

Commit

Permalink
参数默认设置
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwu123 committed Nov 27, 2018
1 parent 4509528 commit 8fd5344
Show file tree
Hide file tree
Showing 6 changed files with 374 additions and 137 deletions.
10 changes: 4 additions & 6 deletions src/httpRequest/push/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,11 @@ public function getOtherParams()

public function getNotify()
{
if (!$this->getTransmission()) {
return [];
$data = ["transmission_type" => true];
if ($this->getTransmission()) {
$data['transmission_content'] = $this->getTransmission();
}
return [
"transmission_type" => true,
"transmission_content" => $this->getTransmission()
];
return $data;
}

public function getLink()
Expand Down
50 changes: 30 additions & 20 deletions src/template/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,52 +38,62 @@ class Link implements Template
*/
protected $duration_end;

/**
* 获取应用模板
*
* @return array
*/
public function getEntity() :array
{
$res = [
'style' => $this->style,
'url' => $this->url
];
$this->duration_begin && $res['duration_begin'] = $this->duration_begin;
$this->duration_end && $res['duration_end'] = $this->duration_end;
return $res;
}

/**
* @param array $style
* @return $this
*/
public function setStyle($style)
public function setStyle(array $style)
{
$this->style = $style;
return $this;
}

/**
* @param string $url
* @return $this
*/
public function setUrl($url)
public function setUrl(string $url)
{
$this->url = $url;
return $this;
}

/**
* @param string $duration_begin
* @return $this
*/
public function setDurationBegin($duration_begin)
public function setDurationBegin(string $duration_begin)
{
$this->duration_begin = $duration_begin;
return $this;
}

/**
* @param string $duration_end
* @return $this
*/
public function setDurationEnd($duration_end)
public function setDurationEnd(string $duration_end)
{
$this->duration_end = $duration_end;
return $this;
}



/**
* 获取应用模板
*
* @return array
*/
public function getEntity() :array
{
$res = [
'style' => $this->style,
'url' => $this->url
];
$this->duration_begin && $res['duration_begin'] = $this->duration_begin;
$this->duration_end && $res['duration_end'] = $this->duration_end;
return $res;
}


Expand Down
46 changes: 25 additions & 21 deletions src/template/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,56 +58,60 @@ class Message implements Template
*/
const MSG_TYPE_TRANSMISSION = 'transmission';


/**
* 获取实体
*
* @return array
*/
public function getEntity(): array
{
return [
'appkey' => $this->app_key,
'is_offline' => $this->is_offline,
'offline_expire_time' => $this->expire_time,
'msgtype' => $this->msgtype,
];
}

/**
* @param string $app_key
* @return $this
*/
public function setAppKey($app_key)
public function setAppKey(string $app_key)
{
$this->app_key = $app_key;
return $this;
}

/**
* @param bool $is_offline
* @return $this
*/
public function setIsOffline($is_offline)
public function setIsOffline(bool $is_offline)
{
$this->is_offline = $is_offline;
return $this;
}

/**
* @param float|int $expire_time
* @return $this
*/
public function setExpireTime($expire_time)
{
$this->expire_time = $expire_time;
return $this;
}

/**
* @param string $msgtype
* @return $this
*/
public function setMsgtype($msgtype)
public function setMsgtype(string $msgtype)
{
$this->msgtype = $msgtype;
return $this;
}

public function getMsgtype()


/**
* 获取实体
*
* @return array
*/
public function getEntity(): array
{
return $this->msgtype;
return [
'appkey' => $this->app_key,
'is_offline' => $this->is_offline,
'offline_expire_time' => $this->expire_time,
'msgtype' => $this->msgtype,
];
}
}
26 changes: 18 additions & 8 deletions src/template/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Notification implements Template
{
/**
* 通知栏消息布局样式,详见Style说明
* @var array
* @var Style
*/
protected $style;

Expand Down Expand Up @@ -56,43 +56,53 @@ public function getEntity() : array
}

/**
* @param array $style
* @param Style $style
* @return $this
*/
public function setStyle($style)
public function setStyle(Style $style)
{
$this->style = $style;
$this->style = $style->getEntity();
return $this;
}

/**
* @param bool $transmission_type
* @return $this
*/
public function setTransmissionType($transmission_type)
public function setTransmissionType(bool $transmission_type)
{
$this->transmission_type = $transmission_type;
return $this;
}

/**
* @param string $transmission_content
* @return $this
*/
public function setTransmissionContent($transmission_content)
public function setTransmissionContent(string $transmission_content)
{
$this->transmission_content = $transmission_content;
return $this;
}

/**
* @param string $duration_begin
* @return $this
*/
public function setDurationBegin($duration_begin)
public function setDurationBegin(string $duration_begin)
{
$this->duration_begin = $duration_begin;
return $this;
}

/**
* @param string $duration_end
* @return $this
*/
public function setDurationEnd($duration_end)
public function setDurationEnd(string $duration_end)
{
$this->duration_end = $duration_end;
return $this;
}


Expand Down
Loading

0 comments on commit 8fd5344

Please sign in to comment.