Skip to content

Instantly share code, notes, and snippets.

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 AhmedHelalAhmed/d6dc37493e158b9b3fc38cb79c8de258 to your computer and use it in GitHub Desktop.
Save AhmedHelalAhmed/d6dc37493e158b9b3fc38cb79c8de258 to your computer and use it in GitHub Desktop.
extracting conditions to meaningful functions
<?php
if (
$employee['age'] < '40'
&& $employee['medical_health'] == 'healthy'
&& $employee ['work_happits'] != 'bad'
)
{
// do somethings
}
//what about if we extracted the condition to a meaningful function
if (canWork($employee))
{
//do something
}
function canWork($employee)
{
return $employee['age'] < '40'
&& $employee['medical_health'] == 'healthy'
&& $employee ['work_happits'] != 'bad';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment