Created
October 8, 2018 16:26
-
-
Save joaorobertopb/e183797c9d55e2829dfcf999f2a62557 to your computer and use it in GitHub Desktop.
Evite o uso de flags como parâmetro! Porquê? porque o uso de flags indicam que essa função faz mais de uma coisa. Lembre-se, funções devem fazer apenas uma coisa!
This file contains hidden or 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 | |
//Ruim | |
function createFile(string $name, bool $temp = false): void | |
{ | |
if ($temp) { | |
touch('./temp/'.$name); | |
} else { | |
touch($name); | |
} | |
} | |
//Bom | |
function createFile(string $name): void | |
{ | |
touch($name); | |
} | |
function createTempFile(string $name): void | |
{ | |
touch('./temp/'.$name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment