className = $this->getClassNameFromInstance($_objectInstance); if ($_priority < self::HIGHEST_PRIORITY || $_priority > self::LOWEST_PRIORITY) { throw new Exception("Invalid priority for ScheduledTask '$this->className.$_methodName': $_priority"); } $this->objectInstance = $_objectInstance; $this->methodName = $_methodName; $this->scheduledTime = $_scheduledTime; $this->methodParameter = $_methodParameter; $this->priority = $_priority; } protected function getClassNameFromInstance($_objectInstance) { $namespaced = get_class($_objectInstance); $class = explode('\\', $namespaced); return end($class); } /** * Return the object instance on which the method should be executed * @return string */ public function getObjectInstance() { return $this->objectInstance; } /** * Return class name * @return string */ public function getClassName() { return $this->className; } /** * Return method name * @return string */ public function getMethodName() { return $this->methodName; } /** * Return method parameter * @return string */ public function getMethodParameter() { return $this->methodParameter; } /** * Return scheduled time * @return ScheduledTime */ public function getScheduledTime() { return $this->scheduledTime; } /** * Return the rescheduled time in milliseconds * @return int */ public function getRescheduledTime() { return $this->getScheduledTime()->getRescheduledTime(); } /** * Return the task priority. The priority will be an integer whose value is * between ScheduledTask::HIGH_PRIORITY and ScheduledTask::LOW_PRIORITY. * * @return int */ public function getPriority() { return $this->priority; } public function getName() { return self::getTaskName($this->getClassName(), $this->getMethodName(), $this->getMethodParameter()); } static public function getTaskName($className, $methodName, $methodParameter = null) { return $className . '.' . $methodName . ($methodParameter == null ? '' : '_' . $methodParameter); } }