protected function process(array $files) { $this->output = new LimeOutput(); foreach ($files as $file) { $command = new LimeShellCommand($file, array('coverage' => true)); $command->execute(); // script failed if ($command->getStatus() != LimeShell::SUCCESS) { $this->output->echoln(sprintf('Warning: %s returned status %d, results may be inaccurate', $file, $command->getStatus()), LimeOutput::ERROR); } // script succeeded, coverage not readable if (false === ($coverage = @unserialize($command->getOutput()))) { if ($command->getStatus() == LimeShell::SUCCESS) { throw new Exception(sprintf('Unable to unserialize coverage for file "%s"', $file)); } } else { foreach ($coverage as $file => $lines) { if (!isset($this->coverage[$file])) { $this->coverage[$file] = $lines; } else { foreach ($lines as $line => $flag) { if ($flag == self::COVERED) { $this->coverage[$file][$line] = 1; } } } } } } }
public function __construct($code) { $file = tempnam(sys_get_temp_dir(), 'lime'); file_put_contents($file, '<?php ' . $code); parent::__construct($file); }