Created
March 3, 2019 22:07
-
-
Save pierswarmers/08de0db3d0fd0815772e6a38bf47e208 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template name="coll" value="class $COLLECTION$ implements \Countable, \IteratorAggregate { private $$$INTERNAL_STORE$; public function __construct($ENCAPSULATED_TYPE$ ... $$$INTERNAL_STORE$) { $this->$INTERNAL_STORE$ = $$$INTERNAL_STORE$; } public function count(): int { return count($this->$INTERNAL_STORE$); } /** * @return \Traversable|$ENCAPSULATED_TYPE$[] */ public function getIterator(): \Traversable { foreach ($this->$INTERNAL_STORE$ as $$$ITEM_VAR$) { yield $$$ITEM_VAR$; } } }" description="Typed immutable collection" toReformat="true" toShortenFQNames="true"> | |
| <variable name="COLLECTION" expression="" defaultValue="" alwaysStopAt="true" /> | |
| <variable name="INTERNAL_STORE" expression="camelCase(COLLECTION)" defaultValue="" alwaysStopAt="false" /> | |
| <variable name="ENCAPSULATED_TYPE" expression="capitalize(firstWord(spaceSeparated(COLLECTION)))" defaultValue="" alwaysStopAt="true" /> | |
| <variable name="ITEM_VAR" expression="camelCase(ENCAPSULATED_TYPE)" defaultValue="" alwaysStopAt="false" /> | |
| <context> | |
| <option name="PHP" value="true" /> | |
| </context> | |
| </template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment