$s) { if ($s == false) return false; } return true; } public function __construct($workspace, $folderKey) { $this->workspace = $workspace; $this->folderKey = $folderKey; } public function parseFile($filename) { if (!self::open($filename)) { return false; } $this->verifiedEntries = array(); while ($row = self::getVerifiedRow()) { $this->verifiedEntries[] = $row; //self::incrementTime($row); } self::close(); return true; } public function verify() { $dir = "converted/{$this->folderKey}/"; $filename = $dir . $this->workspace . ".csv"; if (!self::open($filename)) { return false; } $this->notFound = array(); while ($row = self::getRebasedRow()) { $found = false; for ($i = 0; $i < count($this->verifiedEntries); $i++) { if ($this->rowEquals($row, $this->verifiedEntries[$i])) { $found = true; break; } } if (!$found) { $this->notFound[] = $row; echo(print_r($row)); echo('
'); } } self::close(); if (count($this->notFound) == 0) { touch($dir . $this->workspace . '.verified'); return true; } $this->lastErr = 'Not all entries were found in verification file.'; return false; } private function getVerifiedRow() { $data = fgetcsv($this->file); if (!$data) return false; $row = new stdClass(); $row->user = $data[0]; $row->email = $data[1]; $row->client = $data[2]; $row->project = $data[3]; $row->description = $data[5]; $row->duration = $data[11]; return $row; } private function getRebasedRow() { $data = fgetcsv($this->file); if (!$data) return false; $row = new stdClass(); $row->user = $data[0]; $row->email = $data[1]; $row->client = $data[2]; $row->project = $data[3]; $row->description = $data[4]; $row->duration = $data[7]; return $row; } private function rowEquals($a, $b) { if ($a->user != $b->user) return false; if ($a->email != $b->email) return false; if ($a->client != $b->client) return false; if ($a->project != $b->project) return false; if ($a->description != $b->description) return false; if ($a->duration != $b->duration) return false; return true; } }