AcMailer\Controller\Plugin\Factory\SendMailPluginAbstractFactory::camelCaseToUnderscore PHP Method

camelCaseToUnderscore() protected method

protected camelCaseToUnderscore ( $value )
    protected function camelCaseToUnderscore($value)
    {
        if (!is_scalar($value) && !is_array($value)) {
            return $value;
        }
        if (StringUtils::hasPcreUnicodeSupport()) {
            $pattern = ['#(?<=(?:\\p{Lu}))(\\p{Lu}\\p{Ll})#', '#(?<=(?:\\p{Ll}|\\p{Nd}))(\\p{Lu})#'];
            $replacement = ['_\\1', '_\\1'];
        } else {
            $pattern = ['#(?<=(?:[A-Z]))([A-Z]+)([A-Z][a-z])#', '#(?<=(?:[a-z0-9]))([A-Z])#'];
            $replacement = ['\\1_\\2', '_\\1'];
        }
        return preg_replace($pattern, $replacement, $value);
    }