-
-
Save pix-art/49487f2c7db486cffa415434377849e2 to your computer and use it in GitHub Desktop.
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 ExampleService | |
{ | |
//Dry Violation | |
public function doThis(Example $example) | |
{ | |
if (!$example->isAwesome()) { | |
throw new NotAwesomeException("This is not an awesome example!"); | |
} | |
//Do this | |
} | |
public function doThat(Example $example) | |
{ | |
if (!$example->isAwesome()) { | |
throw new NotAwesomeException("This is not an awesome example!"); | |
} | |
//Do that | |
} | |
//Good example: | |
public function doThis(Example $example) | |
{ | |
$this->isAwesomeExample($example); | |
//Do this | |
} | |
public function doThat(Example $example) | |
{ | |
$this->isAwesomeExample($example); | |
//Do that | |
} | |
private function isAwesomeExample(Example $example) | |
{ | |
if (!$example->isAwesome()) { | |
throw new NotAwesomeException("This is not an awesome example!"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment