Question

I am having an issue with camelize/uncamelize (\Phalcon\Text)

My understanding is that this function creates camel case strings like ucwords() or ucfirst()

The following tests reveal: This test passes:

camelize:

  • nice -> Nice
  • nice weather -> NiceWeather (Not sure if this should be like that. The space is stripped out. If this is the intended behavior then we need to add it to the docs)
  • nice_weather -> NiceWeather (Why does the underscore disappear? If this is the intended behavior then we need to add it to the docs)
  • nIcE -> Nice

uncamelize:

  • Nice -> nice
  • Nice Weather -> nice weather
  • Nice_Weather -> nice_weather
  • NIcE -> nic_e (the capital letter switches to underscore)
Was it helpful?

Solution

The camelize/uncamelize methods are intended to convert strings with underscores to camel case ones. Specifically, these methods are used by Phalcon\Model to convert table names to their respective classes and vice versa. Thus, we can get the name of a table from the class name.

Reference: http://docs.phalconphp.com/en/latest/api/Phalcon_Text.html

OTHER TIPS

Reference: http://docs.phalconphp.com/en/latest/api/Phalcon_Text.html

Hi, we need to change the example of uncamelize:

0.4.x:

- <?php Phalcon_Text::camelize('CocoBongo'); //coco_bongo
+ <?php Phalcon_Text::uncamelize('CocoBongo'); //coco_bongo

0.5.x:

- <?php Phalcon\Text::camelize('CocoBongo'); //coco_bongo
+ <?php Phalcon\Text::uncamelize('CocoBongo'); //coco_bongo
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top