for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace CloudyCity\TencentMarketingSDK\Kernel\Http\Parameters;
use Carbon\Carbon;
class TimeRange
{
/**
* Starting time.
*
* @var Carbon
*/
protected $start;
* End time.
protected $end;
* TimeRange constructor.
* @param null $start
$start
null
* @param null $end
$end
public function __construct($start = null, $end = null)
$this->start($start);
$this->end($end);
}
* Set start time.
* @param $start
* @return $this
public function start($start)
if ($start) {
$this->start = Carbon::make($start);
return $this;
* Set end time.
* @param $end
public function end($end)
if ($end) {
$this->end = Carbon::make($end);
* Check start time and end time.
* @throws \Exception
protected function checkTimeRange()
if (!($this->start instanceof Carbon)) {
$this->start
Carbon\Carbon
throw new \Exception('开始时间不能为空');
if (!($this->end instanceof Carbon)) {
$this->end
throw new \Exception('结束时间不能为空');
* Get the instance as an array.
* @return array
protected function __toArray()
return [
'start_time' => $this->start->getTimestamp(),
'end_time' => $this->end->getTimestamp(),
];
* Check timeCheck time and get the instance as an array.
public function toArray()
$this->checkTimeRange();
return $this->__toArray();