Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@shama shama commented Mar 17, 2011

Is that actual code being used?

@josegonzalez

This comment has been minimized.

Copy link
Owner Author

@josegonzalez josegonzalez commented Mar 17, 2011

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

This comment has been minimized.

Copy link

@paatsinsuwan paatsinsuwan commented Oct 6, 2011

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

@josegonzalez

This comment has been minimized.

Copy link
Owner Author

@josegonzalez josegonzalez commented Oct 6, 2011

no thats a static class

@josegonzalez

This comment has been minimized.

Copy link
Owner Author

@josegonzalez josegonzalez commented Oct 6, 2011

wait

@paatsinsuwan

This comment has been minimized.

Copy link

@paatsinsuwan paatsinsuwan commented Oct 6, 2011

hahaha, cool

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