Skip to content

Instantly share code, notes, and snippets.

@mcsee

mcsee/wrapper.php

Last active Jan 27, 2021
Embed
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() {
$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