Introduce rest api

opening bracket on the same if line (PSR-2 standards).
Prefere elseif to else if (PSR-2 standards).