Skip to content

Instantly share code, notes, and snippets.



Last active Jan 27, 2021
What would you like to do?
final class Calculator {
private $cachedResults;
function computeSomething() {
if (isset($this->cachedResults)) {
return $this->cachedResults;
$this->cachedResults = $this->logAndComputeSomething();
private function logAndComputeSomething() {
$result = $this->basicComputeSomething();
return $result;
private function basicComputeSomething() {
/// Do Real work here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment