Consider writing the class below:
class SomeClass
{
/** @var array */
private $files;
/** @var string */
private $productName;
/** @var bool */
private $singlePage;
/** @var bool */
private $signatureRequested;
function __construct(array $files, string $productName, bool $singlePage, bool $signatureRequested = true)
{
$this->files = $files;
$this->productName = $productName;
$this->singlePage = $singlePage;
$this->signatureRequested = $signatureRequested;
}
}
$files
, and other parameters are listed 4 times - you have to type the parameter name and then copy & paste it, or enter it 3 times into the above boiler template code. Is there a way to reduce the work it requires to type up all this code?
It seems to me like ideally I'd want something where I can specify the parameters I need to be initialized in the constructor just once, and some mechanism will go ahead and fill in the remaining boilerplate code.
Is there such a mechanism/code construct?