Last active
August 21, 2023 14:52
-
-
Save mcsee/dd988af705942cfafd5811df60acaed2 to your computer and use it in GitHub Desktop.
This file contains 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
<? | |
final class Calculator { | |
private $cachedResults; | |
function computeSomething() { | |
if (isset($this->cachedResults)) { | |
return $this->cachedResults; | |
} | |
$this->cachedResults = $this->logAndComputeSomething(); | |
} | |
private function logAndComputeSomething() { | |
$this->logProcessStart(); | |
$result = $this->basicComputeSomething(); | |
$this->logProcessEnd(); | |
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