Last active
June 16, 2020 14:24
-
-
Save jarnheimer/3a91831e0f0e041fc5f838ebfe37d61d to your computer and use it in GitHub Desktop.
Refactoring code test PHP
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 | |
/** | |
* Is the bar open | |
* | |
* @return bool | |
*/ | |
function isBarOpen($day) | |
{ | |
if ($day) { | |
if (is_string($day)) { | |
if ($day == 'friday' || $day == 'Friday') { | |
return true; | |
} elseif ($day == 'saturday' || $day == 'Saturday') { | |
return true; | |
} elseif ($day == 'sunday' || $day == 'Sunday') { | |
return true; | |
} else { | |
return 0; | |
} | |
} else { | |
return 0; | |
} | |
} else { | |
return 0; | |
} | |
} |
Backward compatibility is not required.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A junior developer has written a function which will determine if the bar is open or not. It should return
true
orfalse
. Your task is to help the junior developer to improve the code. The test is limited, so you don't need to change anything outside line 10-27.