Skip to content

Instantly share code, notes, and snippets.

@amaelftah
Last active July 14, 2018 11:49
Show Gist options
  • Save amaelftah/96c0bb23ed9c934f8967eb5149fdf834 to your computer and use it in GitHub Desktop.
Save amaelftah/96c0bb23ed9c934f8967eb5149fdf834 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