You cannot overload such functions in PHP. If you do this:
class A {
public function __construct() { }
public function __construct($a, $b) { }
}
your code will not compile with an error that you cannot update __construct().
A way to do this with optional arguments.
function __construct($service, $action, $security = '') {
if (empty($service) || empty($action)) {
throw new Exception("Both service and action must have a value");
}
$this->$mService = $service;
$this->$mAction = $action;
$this->$mHasSecurity = false;
if (!empty($security)) {
$this->$mHasSecurity = true;
$this->$mSecurity = $security;
}
}