Scalr::decamelize PHP Method

decamelize() public static method

Decamelizes a string
public static decamelize ( string $str ) : string
$str string A string
return string Returns decamelized string
    public static function decamelize($str)
    {
        return strtolower(preg_replace_callback('/([a-z])([A-Z]+)/', function ($m) {
            return $m[1] . '_' . $m[2];
        }, $str));
    }

Usage Example

Example #1
0
 /**
  * Constructor
  *
  * @throws  \Scalr\Exception\AnalyticsException
  */
 public function __construct()
 {
     $this->timelineEvent = new TimelineEventEntity();
     $request = \Scalr::getContainer()->request;
     $this->user = $request instanceof Scalr_UI_Request ? $request->getUser() : null;
     $this->timelineEvent->userId = $this->user->id;
     $constName = 'Scalr\\Stats\\CostAnalytics\\Entity\\TimelineEventEntity::EVENT_TYPE_' . strtoupper(substr(\Scalr::decamelize(preg_replace('/^.+\\\\([\\w]+)$/', '\\1', get_class($this))), 0, -6));
     if (!defined($constName)) {
         throw new AnalyticsException(sprintf("Constant '%s' is not defined.", $constName));
     }
     $this->timelineEvent->eventType = constant($constName);
 }
All Usage Examples Of Scalr::decamelize