Last active
August 29, 2015 14:01
-
-
Save aramonc/ed06833a16249039dbf2 to your computer and use it in GitHub Desktop.
How bad is it to have code like this for readability & maintainability
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 | |
if($paramFetcher['owner'] != null && ($owner = $userMgr->getById($paramFetcher['owner']))) { | |
$org->setOwner($owner); | |
} | |
?> | |
vs. | |
<?php | |
if($paramFetcher['owner'] != null) { | |
if($owner = $userMgr->getById($paramFetcher['owner'])){ | |
$org->setOwner($owner); | |
} | |
} | |
?> | |
FINAL: | |
<?php | |
$owner = $this->getUserManager()->getById($paramFetcher['owner']); | |
if ($owner) { | |
$org->setOwner($owner); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ended up changing it. I realized I was duplicating some code to get users and that if the parameter for
getById()
isnull
, it will returnnull
. So there was no need to check$paramFetcher['owner']
individually.Thank you all!