An action may be maintained by an incorporated borough, city, or other public corporation of like character in its corporate name, and upon a cause of action accruing to it in its corporate character
(1) upon a contract made with the public corporation;
(2) upon a liability prescribed by law in favor of the public corporation;
(3) to recover a penalty or forfeiture given to the public corporation;
(4) to recover damages for an injury to the corporate rights or property of the public corporation.