Skip to content

Instantly share code, notes, and snippets.

View jensstalder's full-sized avatar

Jens Stalder jensstalder

  • Stalder Studios GmbH
  • Wil SG
View GitHub Profile
@jensstalder
jensstalder / Encapsulating independent scopes within a single function.php
Last active March 11, 2023 18:05
unction that demonstrates how to use closures to generate blocks of independent logic without extracting things into separate methods/functions. This avoids fragmentation of the code and allows to keep the logic in one place if the pieces are not reused/reusable, but still allows for save scoping. As explained by Brian Will: https://youtu.be/QM1…
<?php
/**
* Function that demonstrates how to use closures to generate blocks of independent logic without extracting things into separate methods/functions.
*
* This avoids fragmentation of the code and allows to keep the logic in one place if the pieces are not reused/reusable, but still allows for save scoping.
*
* As explained by Brian Will:
* https://youtu.be/QM1iUe6IofM?t=2255
*/