From dd259f3135dae77fde97982e6ff11f8a5995befa Mon Sep 17 00:00:00 2001 From: Peter Gribanov Date: Wed, 30 Aug 2017 19:14:00 +0300 Subject: [PATCH] correct example of encapsulate conditionals --- README.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4455b29..6b34815 100644 --- a/README.md +++ b/README.md @@ -559,22 +559,21 @@ $singleton = Configuration::getInstance(); ### Encapsulate conditionals **Bad:** + ```php -if ($fsm->state === 'fetching' && is_empty($listNode)) { +if ($article->state === 'published') { // ... } ``` **Good**: -```php -function shouldShowSpinner($fsm, $listNode) { - return $fsm->state === 'fetching' && is_empty($listNode); -} -if (shouldShowSpinner($fsmInstance, $listNodeInstance)) { - // ... +```php +if ($article->isPublished()) { + // ... } ``` + **[⬆ back to top](#table-of-contents)** ### Avoid negative conditionals