Created
July 20, 2020 11:06
-
-
Save bernard-ng/5318a99923844b5111fe48acba925075 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
<?php | |
function countReducer(array $state, $action) { | |
switch($action['type']) { | |
case INCREMENT_ACTION: | |
return array_replace([], $state, ['count' => $state['count'] + 1]); | |
case DECREMENT_ACTION: | |
return array_replace([], $state, ['count' => $state['count'] - 1]); | |
default: | |
return $state; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment