Crontab\Crontab::addJob PHP Method

addJob() public method

Add a new job to the crontab
public addJob ( Crontab\Job $job ) : Crontab
$job Crontab\Job
return Crontab
    public function addJob(Job $job)
    {
        $this->jobs[$job->getHash()] = $job;
        return $this;
    }

Usage Example

 /**
  * Reads cron jobs from a file.
  *
  * @param Crontab $crontab
  * @param string  $filename
  *
  * @return CrontabFileHandler
  * @throws \InvalidArgumentException
  */
 public function parseFromFile(Crontab $crontab, $filename)
 {
     if (!is_readable($filename)) {
         throw new \InvalidArgumentException('File ' . $filename . ' is not readable.');
     }
     $file = file_get_contents($filename);
     foreach ($this->parseString($file) as $job) {
         $crontab->addJob($job);
     }
     return $this;
 }
All Usage Examples Of Crontab\Crontab::addJob