A port of main php functions to ruby methods to easy php to ruby code migration