I was writing some code and I began to feel a little uncomfortable with messy parent::__construct
calls and I was wondering firstly is it bad OOP practice and secondly is there a cleaner way to do it? See the particularly extreme example below that triggered my question.
<?php
class BrowseNodeLookupRequest extends Request {
protected $BrowseNodeId;
public function __construct($Service, $AWSAccessKeyID, $AssociateTag,
$Operation, $MerchantID = null, $ResponseGroup = null,
$Version = null, $Style = null, $ContentType = null,
$XMLEscaping = null, $Validate = null, $BrowseNodeId) {
parent::__construct($Service, $AWSAccessKeyID, $AssociateTag,
$Operation, $MerchantID, $ResponseGroup, $Version, $Style,
$ContentType, $XMLEscaping);
$this->setBrowseNodeId($BrowseNodeId);
}
protected function setBrowseNodeId($BrowseNodeId) {
if (is_string($BrowseNodeId)) {
$this->BrowseNodeId = $BrowseNodeId;
} else {
throw new Exception('BrowseNodeLookupRequest Parameter (BrowseNodeId
) Must be a String');
}
}
}
?>