public function isValid() { if (is_string($this->raw) && !empty($this->raw)) { return true; } if (!isset($this->title)) { $this->title = ""; } else { if (!is_string($this->title) || empty($this->title)) { return false; } } if (!isset($this->content)) { $this->content = ""; } else { if (!is_string($this->content) || empty($this->content)) { return false; } } if (!is_int($this->type) || $this->type < self::TYPE_NOTIFICATION || $this->type > self::TYPE_MESSAGE) { return false; } if (!is_int($this->multiPkg) || $this->multiPkg < 0 || $this->multiPkg > 1) { return false; } if ($this->type == self::TYPE_NOTIFICATION) { if (!$this->style instanceof Style || !$this->action instanceof ClickAction) { return false; } if (!$this->style->isValid() || !$this->action->isValid()) { return false; } } if (isset($this->expireTime)) { if (!is_int($this->expireTime) || $this->expireTime > 3 * 24 * 60 * 60) { return false; } } else { $this->expireTime = 0; } if (isset($this->sendTime)) { if (strtotime($this->sendTime) === false) { return false; } } else { $this->sendTime = "2013-12-19 17:49:00"; } foreach ($this->acceptTimes as $value) { if (!$value instanceof TimeInterval || !$value->isValid()) { return false; } } if (isset($this->custom)) { if (!is_array($this->custom)) { return false; } } else { $this->custom = array(); } if (isset($this->loopInterval)) { if (!(is_int($this->loopInterval) && $this->loopInterval > 0)) { return false; } } if (isset($this->loopTimes)) { if (!(is_int($this->loopTimes) && $this->loopTimes > 0)) { return false; } } if (isset($this->loopInterval) && isset($this->loopTimes)) { if (($this->loopTimes - 1) * $this->loopInterval + 1 > self::MAX_LOOP_TASK_DAYS) { return false; } } return true; }