const state = new WeakMap();
function privateStuff(ctx) {
const bar = state.get(ctx).bar;
// ... do something
return changedBar;
}
export default class Foo {
constructor(foo, bar) {
state.set(this, {foo, bar});
}
get foo() {
return state.get(this).foo;
}
}
public function handle($postId=null, $text=null) {
if ($postId) {
return $this->handleByPostID($postId);
}
return handleByText($text);
}
private function handleByPostID(int $postId) {
if ($this->hasCustomTime($postId)) {
return $this->getCustomTimeByID($postId);
}
return $this->handleByText(
$this->getPostTextById($postId)
);
}
private function handleByText(string $text) {
return $this->getTimeRead($text);
}