Zend_Filter_Inflector Usage

2 messages Options
Embed this post
Permalink
prodigitalson

Zend_Filter_Inflector Usage

Reply Threaded More More options
Print post
Permalink
IS there a way to call Zend_Filter_Inflector::filter() with a simple string argument?

I jsut want to change:

thirdPartyMethodProxy
TO
third_party_method_proxy

But i dont really want to always be passing an array argument to filter since there are no segments for replacement or different rules.

I know i can just manually construct and run the filters, but i wanted ase hoping to use the inflecto to manage the chain. I can always subclass it i suppose but it seems like i shouldnt have to :-)
Ralph Schindler-2

Re: Zend_Filter_Inflector Usage

Reply Threaded More More options
Print post
Permalink
The inflector is all about replacing things with specific rules.  If you
want to do what you are asking, the simplest way is to do this:

$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_Word_CamelCaseToUnderscore());
$filter->addFilter(new Zend_Filter_StringToLower());

$text = 'thirdPartyMethodProxy';

$filter->filter($text); // third_party_method_proxy

hope that helps,
Ralph

prodigitalson wrote:

> IS there a way to call Zend_Filter_Inflector::filter() with a simple string
> argument?
>
> I jsut want to change:
>
> thirdPartyMethodProxy
> TO
> third_party_method_proxy
>
> But i dont really want to always be passing an array argument to filter
> since there are no segments for replacement or different rules.
>
> I know i can just manually construct and run the filters, but i wanted ase
> hoping to use the inflecto to manage the chain. I can always subclass it i
> suppose but it seems like i shouldnt have to :-)