flow icon indicating copy to clipboard operation
flow copied to clipboard

Integration with symfony/string for better strings manipulation

Open norberttech opened this issue 1 year ago • 5 comments

That would be very helpful integration from text processing point of view.

Library: https://github.com/symfony/string

It should be pretty straightforward since we would just need to create a scalar function for each of the methods string methods.

I think we can make it a part of TextAdapter, just put all scalar functions inside of it. ~All those functions should be also added to TextAdapter DSL functions, with a text_ prefix.~ Those functions should exist in the src/core/etl/src/Flow/ETL/Function namespace and be part of the core ETL.

We don't even need to create for them dedicated DSL functions (as they can only operate on string), what we can do is simply expose them through src/core/etl/src/Flow/ETL/Function/ScalarFunctionChain.php so they would all be available through ref()->xxxx

Documentation: How to create scalar function

norberttech avatar Jan 01 '25 15:01 norberttech

How does it differ from Symfony String?

stloyd avatar Jan 01 '25 15:01 stloyd

Interesting, I would need to go through entire APIs of both libs to understand which one provides more value. symfony/string comes with some dependencies, that's one thing. However to provide more text manipulation options we should also take a look at https://github.com/voku/portable-utf8

So the question is what makes more sense, portable-ascii + portable-utf8 or symfony/string?

norberttech avatar Jan 01 '25 16:01 norberttech

I asked GitHub copilot which one we should use and he said symfony/string but without any good justification 😅 I wouldn't trust it, comparing the APIs - that's what we need to do first

norberttech avatar Jan 01 '25 16:01 norberttech

https://symfony.com/doc/current/string.html#methods-to-change-case just noticed that symfony/string can also replace an existing case converting dependency. So I guess we have our answer about which library to use

norberttech avatar Jan 05 '25 22:01 norberttech

This is an example of how easy it is to create Scalar Functions: https://github.com/flow-php/flow/pull/1337

norberttech avatar Jan 06 '25 18:01 norberttech

With recent PRs:

  • #1635,
  • #1617,
  • #1607

I would say that this could be considered as done, no?

stloyd avatar May 09 '25 04:05 stloyd

I would say that this could be considered as done, no?

Hmm the initial idea was to cover all functions from String Component by scalar functions, so I guess we are still missing few but I need to spend some time, go through list of functions and list what we already have and what we are still missing

norberttech avatar May 09 '25 09:05 norberttech