/** * @return void */ private function runJobs(array $jobs) { foreach ($jobs as $job) { if (is_string($job) && preg_match('#^(https?|local|remote):(.+)#', $job, $m)) { if ($m[1] === 'local') { $out = @system($m[2], $code); $err = $code !== 0; } elseif ($m[1] === 'remote') { $out = $this->server->execute($m[2]); $err = FALSE; } else { $err = ($out = @file_get_contents($job)) === FALSE; } $this->logger->log("{$job}: {$out}"); if ($err) { throw new \RuntimeException("Error in job {$job}"); } } elseif (is_callable($job)) { if ($job($this->server, $this->logger, $this) === FALSE) { throw new \RuntimeException('Error in job'); } } else { throw new \InvalidArgumentException("Invalid job {$job}."); } } }