September 15, 2022 ∙ by https://sebastiandedeyne.com/ Look at this code, I have no idea what false, false, true conveys. $page->render(false, false, true); A pattern I often see in older code is an associative array as the single parameter.
class Page { private bool $showFooter = true; private bool $showHeader = true; private bool $includeAssets = false; public function showFooter(bool $showFooter): self { $this->showFooter = $showFooter; return $this; } public function showHeader(bool $showHeader): self { $this->showHeader = $showHeader; return $this; } public function includeAssets(bool $includeAssets): self { $this->includeAssets = $includeAssets; return $this; }
Proper IDE support, type safety, no internal state required, keeps the object’s public methods to a minimum.