@@ -337,7 +337,8 @@ function parseBetterJSAlternative($code) {
337337}
338338```
339339
340- ** Good** :
340+ ** Good:**
341+
341342``` php
342343function tokenize($code) {
343344 $regexes = [
@@ -397,9 +398,11 @@ a good abstraction, do it! Don't repeat yourself, otherwise you'll find yourself
397398updating multiple places anytime you want to change one thing.
398399
399400** Bad:**
401+
400402``` php
401- function showDeveloperList($developers) {
402- foreach($developers as $developer) {
403+ function showDeveloperList($developers)
404+ {
405+ foreach ($developers as $developer) {
403406 $expectedSalary = $developer->calculateExpectedSalary();
404407 $experience = $developer->getExperience();
405408 $githubLink = $developer->getGithubLink();
@@ -413,8 +416,9 @@ function showDeveloperList($developers) {
413416 }
414417}
415418
416- function showManagerList($managers) {
417- foreach($managers as $manager) {
419+ function showManagerList($managers)
420+ {
421+ foreach ($managers as $manager) {
418422 $expectedSalary = $manager->calculateExpectedSalary();
419423 $experience = $manager->getExperience();
420424 $githubLink = $manager->getGithubLink();
@@ -429,13 +433,15 @@ function showManagerList($managers) {
429433}
430434```
431435
432- ** Good** :
436+ ** Good:**
437+
433438``` php
434- function showList($employees) {
435- foreach($employees as $employe) {
436- $expectedSalary = $employe->calculateExpectedSalary();
437- $experience = $employe->getExperience();
438- $githubLink = $employe->getGithubLink();
439+ function showList($employees)
440+ {
441+ foreach ($employees as $employe) {
442+ $expectedSalary = $employe->calculateExpectedSalary();
443+ $experience = $employe->getExperience();
444+ $githubLink = $employe->getGithubLink();
439445 $data = [
440446 $expectedSalary,
441447 $experience,
@@ -446,6 +452,24 @@ function showList($employees) {
446452 }
447453}
448454```
455+
456+ ** Very good:**
457+
458+ It is better to use a compact version of the code.
459+
460+ ``` php
461+ function showList($employees)
462+ {
463+ foreach ($employees as $employe) {
464+ render([
465+ $employe->calculateExpectedSalary(),
466+ $employe->getExperience(),
467+ $employe->getGithubLink()
468+ ]);
469+ }
470+ }
471+ ```
472+
449473** [ ⬆ back to top] ( #table-of-contents ) **
450474
451475### Don't use flags as function parameters
0 commit comments