PHP Class snippet was working wrong