src/Cronner/Cronner.php
public function addTasks($tasks) : self
	{
		$tasksId = $this->createIdFromObject($tasks);
		if (in_array($tasksId, $this->registeredTaskObjects)) {
			throw new InvalidArgumentException("Tasks with ID '" . $tasksId . "' have been already added.");
		}

		$reflection = new ClassType($tasks);
		$methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC);
		foreach ($methods as $method) {
			if (!Strings::startsWith($method->getName(), '__') && $method->hasAnnotation(Parameters::TASK)) {
				$task = new Task($tasks, $method, $this->timestampStorage);
				if (array_key_exists($task->getName(), $this->tasks)) {
					throw new DuplicateTaskNameException('Cannot use more tasks with the same name "' . $task->getName() . '".');
				}
				$this->tasks[$task->getName()] = $task;
			}
		}
		$this->registeredTaskObjects[] = $tasksId;

		return $this;
	}
public function addTasks($tasks) : self
	{
		$tasksId = $this->createIdFromObject($tasks);
		if (in_array($tasksId, $this->registeredTaskObjects)) {
			throw new InvalidArgumentException("Tasks with ID '" . $tasksId . "' have been already added.");
		}

		$reflection = new ClassType($tasks);
		$methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC);
		foreach ($methods as $method) {
			if (!Strings::startsWith($method->getName(), '__') && $method->hasAnnotation(Parameters::TASK)) {
				$task = new Task($tasks, $method, $this->timestampStorage);
				if (array_key_exists($task->getName(), $this->tasks)) {
					throw new DuplicateTaskNameException('Cannot use more tasks with the same name "' . $task->getName() . '".');
				}
				$this->tasks[$task->getName()] = $task;
			}
		}
		$this->registeredTaskObjects[] = $tasksId;

		return $this;
	}
public function addTasks ( $ tasks ) : self { $ tasksId = $ this -> createIdFromObject ( $ tasks ) ; if ( in_array ( $ tasksId , $ this -> registeredTaskObjects ) ) { throw new InvalidArgumentException ( "Tasks with ID '" . $ tasksId . "' have been already added." ) ; } $ reflection = new ClassType ( $ tasks ) ; $ methods = $ reflection -> getMethods ( ReflectionMethod :: IS_PUBLIC ) ; foreach ( $ methods as $ method ) { if ( ! Strings :: startsWith ( $ method -> getName ( ) , '__' ) && $ method -> hasAnnotation ( Parameters :: TASK ) ) { $ task = new Task ( $ tasks , $ method , $ this -> timestampStorage ) ; if ( array_key_exists ( $ task -> getName ( ) , $ this -> tasks ) ) { throw new DuplicateTaskNameException ( 'Cannot use more tasks with the same name "' . $ task -> getName ( ) . '".' ) ; } $ this -> tasks [ $ task -> getName ( ) ] = $ task ; } } $ this -> registeredTaskObjects [ ] = $ tasksId ; return $ this ; }
Adds task case to be processed when cronner runs. If tasks
with name which is already added are given then throws
an exception.

@param object $tasks
@return Cronner
@throws InvalidArgumentException
Adds task case to be processed when cronner runs . If tasks with name which is already added are given then throws an exception .