Using PHP interfaces in Codeigniter
- by John Stewart
I am trying to find out how can I used PHP interfaces in my MVC design. I want to make sure that the design enforces an interface so that any new module would follow that.
For example:
<?php
interface BaseAPI {
public function postMessage($msg);
}
class ServiceAPI implements BaseAPI {
public function postMessage($msg) { return $msg; }
}
class Service_Two_API implements BaseAPI {
public function postMessage($msg) { return "can't do this: ".$msg; }
}
?>
I want to do this in CI. Is it possible? how should I design it?