Finished the php version and its tests