Created
January 14, 2015 17:25
-
-
Save bearlikelion/1e6b2296bdd1b7d985bc to your computer and use it in GitHub Desktop.
PSR Standards comparison
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 | |
// Current - non-standard code standard we use | |
public function positions() | |
{ | |
$resumes = $this->resumes(false, true); | |
foreach ($resumes as $resume) { | |
$data = json_decode($resume['data']); | |
if (isset($data->employment->entries) && count($data->employment->entries) > 0) { | |
foreach ($data->employment->entries as $job) { | |
$positions[] = ($job->subentries[0]->name); | |
} | |
} | |
} | |
if (isset($positions)) return array_unique($positions); | |
else return 0; | |
} | |
// PSR-2 | |
public function positions() | |
{ | |
$resumes = $this->resumes(false, true); | |
foreach ($resumes as $resume) { | |
$data = json_decode($resume['data']); | |
if (isset($data->employment->entries) && count($data->employment->entries) > 0) { | |
foreach ($data->employment->entries as $job) { | |
$positions[] = ($job->subentries[0]->name); | |
} | |
} | |
} | |
if (isset($positions)) { | |
return array_unique($positions); | |
} else { | |
return 0; | |
} | |
} | |
// PSR-1 + Allman Braces (Laravel's Standard) | |
public function positions() | |
{ | |
$resumes = $this->resumes(false, true); | |
foreach ($resumes as $resume) | |
{ | |
$data = json_decode($resume['data']); | |
if (isset($data->employment->entries) && count($data->employment->entries) > 0) | |
{ | |
foreach ($data->employment->entries as $job) | |
{ | |
$positions[] = ($job->subentries[0]->name); | |
} | |
} | |
} | |
if (isset($positions)) | |
{ | |
return array_unique($positions); | |
} | |
else | |
{ | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment