protected function write($path, $contents) { $fp = fopen($path, 'w'); if (!flock($fp, LOCK_EX)) { return false; } $result = fwrite($fp, $contents); flock($fp, LOCK_UN); fclose($fp); return $result !== false; }