All "Builders" Snippets
build
Generate the build method for builders.
<template name="build" value="public function build(): $TYPE$ { return new $TYPE$($PARAMETERS$$END$); }" description="Build method" toReformat="true" toShortenFQNames="true">
<variable name="TYPE" expression="" defaultValue="regularExpression(phpClassName(), "Builder", "")" alwaysStopAt="false" />
<variable name="PARAMETERS" expression="complete()" defaultValue="" alwaysStopAt="true" />
<context>
<option name="PHP Class Member" value="true" />
</context>
</template>
Live template
fbuild
Generate the encapsulating function for builders.
<template name="fbuild" value="function a$FUNCTIONAME$(): $TYPE$ { 	return new $TYPE$(); }" description="function encapsulating a builder" toReformat="true" toShortenFQNames="true">
<variable name="TYPE" expression="complete()" defaultValue="" alwaysStopAt="true" />
<variable name="FUNCTIONAME" expression="regularExpression(TYPE, "Builder", "")" defaultValue="" alwaysStopAt="true" />
<context>
<option name="PHP Statement" value="true" />
</context>
</template>
Live template
with
Generate a "wither" method for builders.
<template name="with" value="public function with$NAME$($PARAMETER_TYPE$ $$$PARAMETER_NAME$): self { 	$clone = clone $this; 	 	$clone->$PARAMETER_NAME$$END$ = $$$PARAMETER_NAME$; 	 	return $clone; }" description="Create a wither" toReformat="false" toShortenFQNames="true">
<variable name="PARAMETER_TYPE" expression="complete()" defaultValue="" alwaysStopAt="true" />
<variable name="PARAMETER_NAME" expression="complete()" defaultValue="" alwaysStopAt="true" />
<variable name="NAME" expression="" defaultValue="capitalize(PARAMETER_NAME)" alwaysStopAt="false" />
<context>
<option name="PHP Class Member" value="true" />
</context>
</template>
Live template