PHP port of https://github.com/component/path-to-regexp