Skip to content

Instantly share code, notes, and snippets.

@jarnheimer
Last active June 16, 2020 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarnheimer/3a91831e0f0e041fc5f838ebfe37d61d to your computer and use it in GitHub Desktop.
Save jarnheimer/3a91831e0f0e041fc5f838ebfe37d61d to your computer and use it in GitHub Desktop.
Refactoring code test PHP
<?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;
}
}
@jarnheimer
Copy link
Author

A junior developer has written a function which will determine if the bar is open or not. It should return true or false. 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.

@jarnheimer
Copy link
Author

Backward compatibility is not required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment