Skip to content

Instantly share code, notes, and snippets.

@josegonzalez
Created March 17, 2011 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josegonzalez/874914 to your computer and use it in GitHub Desktop.
Save josegonzalez/874914 to your computer and use it in GitHub Desktop.
PHP Variables, method names, and class names are ridiculous
<?php
$classMap = array(
'AggregateRecordSales' => 'band_id',
'BandInfoDaily' => 'team_id',
'DivisionStandings' => 'team_id',
'TeambandPriceCache' => 'teamband_id',
);
$baseClassVar = 'baseClass';
$inflection = 'inflect';
foreach ($classMap as $baseClass => $fieldName) {
${Inflector::pluralize(Inflector::underscore($baseClass))} = ${$$baseClassVar . 'Peer'}::${'retrieveBy' . Inflector::camelize($fieldName)}(${'some' . Inflector::camelize(substr($fieldName, -2))});
}
@shama
Copy link

shama commented Mar 17, 2011

Is that actual code being used?

@josegonzalez
Copy link
Author

No lol, I was screwing around with php and variable variables. Would be AWESOME though, no?

For the record, that Inflector class is ported from CakePHP to be framework agnostic and fully static.

@paatsinsuwan
Copy link

did you forget '$' in $Inflector::camelize(fieldName)

@josegonzalez
Copy link
Author

no thats a static class

@josegonzalez
Copy link
Author

wait

@paatsinsuwan
Copy link

hahaha, cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment