- Constructor should be used only to obtain variables that will be set to a member properties here. No further logic should be done here...
- Following the idea from point 1 there should be another logic that determines what happens next (e.g.
if Object->hasProperty(X) then do x()
, etc.) - Then a comment would be plain and straight forward.
Example:
class Route
{
private $url;
private $methods = array();
/**
* Constructor method, sets the attributes to private member variables
* @param string $url URL pattern
* @param array $methods Methods that should be used with given URL
*/
function __construct($url, $methods = array())
{
$this->url = $url;
$this->methods = $methods;
}
// ...
}