Last active
February 9, 2019 02:06
-
-
Save Anticom/3a78168a604ab9f9cae2f52aac1d3f18 to your computer and use it in GitHub Desktop.
refactor extract boolean expression example (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 | |
class MobilePhone { | |
// example state | |
$state = [ | |
'connectedToWifi' => true, | |
'connectedToCelular' => false, | |
]; | |
public function isOnlineMsg() { | |
if($this->state['connectedToWifi'] || $this->state['cellular']) return 'yes'; | |
return 'no'; | |
} | |
} |
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 | |
class MobilePhone { | |
// example state | |
$state = [ | |
'connectedToWifi' => true, | |
'connectedToCelular' => false, | |
]; | |
public function isOnline() { | |
return $this->state['connectedToWifi'] || $this->state['cellular']; | |
} | |
public function isOnlineMsg() { | |
if($this->isOnline()) return 'yes'; | |
return 'no'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment