@@ -322,7 +322,8 @@ function parseBetterJSAlternative($code) {
322322}
323323```
324324
325- ** Good** :
325+ ** Good:**
326+
326327``` php
327328function tokenize($code) {
328329 $regexes = [
@@ -382,9 +383,11 @@ a good abstraction, do it! Don't repeat yourself, otherwise you'll find yourself
382383updating multiple places anytime you want to change one thing.
383384
384385** Bad:**
386+
385387``` php
386- function showDeveloperList($developers) {
387- foreach($developers as $developer) {
388+ function showDeveloperList($developers)
389+ {
390+ foreach ($developers as $developer) {
388391 $expectedSalary = $developer->calculateExpectedSalary();
389392 $experience = $developer->getExperience();
390393 $githubLink = $developer->getGithubLink();
@@ -398,8 +401,9 @@ function showDeveloperList($developers) {
398401 }
399402}
400403
401- function showManagerList($managers) {
402- foreach($managers as $manager) {
404+ function showManagerList($managers)
405+ {
406+ foreach ($managers as $manager) {
403407 $expectedSalary = $manager->calculateExpectedSalary();
404408 $experience = $manager->getExperience();
405409 $githubLink = $manager->getGithubLink();
@@ -414,10 +418,34 @@ function showManagerList($managers) {
414418}
415419```
416420
417- ** Good** :
421+ ** Good:**
422+
423+ ``` php
424+ function showList($employees)
425+ {
426+ foreach ($employees as $employe) {
427+ $expectedSalary = $employe->calculateExpectedSalary();
428+ $experience = $employe->getExperience();
429+ $githubLink = $employe->getGithubLink();
430+ $data = [
431+ $expectedSalary,
432+ $experience,
433+ $githubLink
434+ ];
435+
436+ render($data);
437+ }
438+ }
439+ ```
440+
441+ ** Very good:**
442+
443+ It is better to use a compact version of the code.
444+
418445``` php
419- function showList($employees) {
420- foreach($employees as $employe) {
446+ function showList($employees)
447+ {
448+ foreach ($employees as $employe) {
421449 render([
422450 $employe->calculateExpectedSalary(),
423451 $employe->getExperience(),
@@ -426,6 +454,7 @@ function showList($employees) {
426454 }
427455}
428456```
457+
429458** [ ⬆ back to top] ( #table-of-contents ) **
430459
431460### Don't use flags as function parameters
0 commit comments