Skip to content

Instantly share code, notes, and snippets.

@bearlikelion
Created January 14, 2015 17:25
Show Gist options
  • Save bearlikelion/1e6b2296bdd1b7d985bc to your computer and use it in GitHub Desktop.
Save bearlikelion/1e6b2296bdd1b7d985bc to your computer and use it in GitHub Desktop.
PSR Standards comparison
<?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