Add StringStyle ScalarFunction#1453
Conversation
Flow PHP - BenchmarksResults of the benchmarks from this PR are compared with the results from 1.x branch. Extractors+-----------------------+-------------------+------+-----+-----------------+------------------+----------------+
| benchmark | subject | revs | its | mem_peak | mode | rstdev |
+-----------------------+-------------------+------+-----+-----------------+------------------+----------------+
| CSVExtractorBench | bench_extract_10k | 1 | 3 | 4.798mb +0.01% | 555.914ms +0.58% | ±0.23% -10.36% |
| JsonExtractorBench | bench_extract_10k | 1 | 3 | 4.871mb +0.01% | 1.063s +0.12% | ±0.43% +7.58% |
| ParquetExtractorBench | bench_extract_10k | 1 | 3 | 86.312mb +0.00% | 887.466ms -1.89% | ±0.17% -57.12% |
| TextExtractorBench | bench_extract_10k | 1 | 3 | 4.528mb +0.02% | 35.403ms +0.64% | ±1.00% -50.48% |
| XmlExtractorBench | bench_extract_10k | 1 | 3 | 4.502mb +0.02% | 603.940ms +0.11% | ±0.21% -78.57% |
+-----------------------+-------------------+------+-----+-----------------+------------------+----------------+
Transformers+-----------------------------+--------------------------+------+-----+------------------+-----------------+----------------+
| benchmark | subject | revs | its | mem_peak | mode | rstdev |
+-----------------------------+--------------------------+------+-----+------------------+-----------------+----------------+
| RenameEntryTransformerBench | bench_transform_10k_rows | 1 | 3 | 127.324mb +0.00% | 71.566ms -2.84% | ±0.28% -80.84% |
+-----------------------------+--------------------------+------+-----+------------------+-----------------+----------------+
Loaders+--------------------+----------------+------+-----+------------------+------------------+----------------+
| benchmark | subject | revs | its | mem_peak | mode | rstdev |
+--------------------+----------------+------+-----+------------------+------------------+----------------+
| CSVLoaderBench | bench_load_10k | 1 | 3 | 63.995mb +0.00% | 101.767ms -2.59% | ±0.80% -50.20% |
| JsonLoaderBench | bench_load_10k | 1 | 3 | 84.342mb +0.00% | 97.764ms -2.43% | ±0.57% +31.43% |
| ParquetLoaderBench | bench_load_10k | 1 | 3 | 161.183mb +0.00% | 20.592s -0.95% | ±0.18% -58.22% |
| TextLoaderBench | bench_load_10k | 1 | 3 | 17.994mb +0.00% | 31.029ms -3.82% | ±0.26% +38.13% |
+--------------------+----------------+------+-----+------------------+------------------+----------------+
Building Blocks+-------------------+----------------------------+------+-----+------------------+------------------+-----------------+
| benchmark | subject | revs | its | mem_peak | mode | rstdev |
+-------------------+----------------------------+------+-----+------------------+------------------+-----------------+
| EntryFactoryBench | bench_entry_factory | 1 | 3 | 105.967mb +0.00% | 452.792ms -1.86% | ±0.51% +319.87% |
| EntryFactoryBench | bench_entry_factory | 1 | 3 | 55.157mb +0.00% | 229.979ms -2.49% | ±1.08% +24.22% |
| EntryFactoryBench | bench_entry_factory | 1 | 3 | 14.679mb +0.00% | 49.957ms -3.23% | ±0.29% +43.59% |
| RowsBench | bench_chunk_10_on_10k | 2 | 3 | 97.010mb +0.00% | 3.092ms -26.26% | ±1.05% -60.69% |
| RowsBench | bench_diff_left_1k_on_10k | 2 | 3 | 114.293mb +0.00% | 186.018ms +0.18% | ±0.34% +15.86% |
| RowsBench | bench_diff_right_1k_on_10k | 2 | 3 | 97.013mb +0.00% | 18.501ms -4.29% | ±1.19% -46.57% |
| RowsBench | bench_drop_1k_on_10k | 2 | 3 | 97.885mb +0.00% | 1.447ms -31.23% | ±3.18% +198.92% |
| RowsBench | bench_drop_right_1k_on_10k | 2 | 3 | 97.885mb +0.00% | 1.372ms -35.18% | ±0.82% -78.74% |
| RowsBench | bench_entries_on_10k | 2 | 3 | 96.046mb +0.00% | 4.582ms -19.61% | ±1.99% -16.11% |
| RowsBench | bench_filter_on_10k | 2 | 3 | 96.575mb +0.00% | 16.981ms -3.37% | ±0.43% -49.44% |
| RowsBench | bench_find_on_10k | 2 | 3 | 96.575mb +0.00% | 17.106ms -2.43% | ±0.91% +70.40% |
| RowsBench | bench_find_one_on_10k | 10 | 3 | 95.266mb +0.00% | 1.894μs -5.30% | ±2.53% +0.00% |
| RowsBench | bench_first_on_10k | 10 | 3 | 95.266mb +0.00% | 0.300μs -25.00% | ±0.00% -100.00% |
| RowsBench | bench_flat_map_on_1k | 2 | 3 | 104.484mb +0.00% | 15.568ms -5.54% | ±1.90% +4.82% |
| RowsBench | bench_map_on_10k | 2 | 3 | 134.551mb +0.00% | 71.602ms -6.07% | ±1.11% -2.23% |
| RowsBench | bench_merge_1k_on_10k | 2 | 3 | 97.095mb +0.00% | 1.250ms -33.22% | ±1.92% +263.45% |
| RowsBench | bench_partition_by_on_10k | 2 | 3 | 100.392mb +0.00% | 66.765ms +2.20% | ±0.61% +2.86% |
| RowsBench | bench_remove_on_10k | 2 | 3 | 98.147mb +0.00% | 3.593ms -23.67% | ±0.55% -77.88% |
| RowsBench | bench_sort_asc_on_1k | 2 | 3 | 95.555mb +0.00% | 43.307ms +1.02% | ±0.76% +12.73% |
| RowsBench | bench_sort_by_on_1k | 2 | 3 | 95.555mb +0.00% | 43.629ms +2.38% | ±0.77% -73.97% |
| RowsBench | bench_sort_desc_on_1k | 2 | 3 | 95.555mb +0.00% | 42.978ms +1.34% | ±0.80% -60.22% |
| RowsBench | bench_sort_entries_on_1k | 2 | 3 | 97.707mb +0.00% | 8.279ms -8.40% | ±0.60% -70.64% |
| RowsBench | bench_sort_on_1k | 2 | 3 | 95.456mb +0.00% | 29.278ms -2.92% | ±1.27% -23.59% |
| RowsBench | bench_take_1k_on_10k | 10 | 3 | 95.266mb +0.00% | 13.282μs -8.95% | ±1.07% +65.15% |
| RowsBench | bench_take_right_1k_on_10k | 10 | 3 | 95.266mb +0.00% | 15.110μs -12.26% | ±2.93% +194.99% |
| RowsBench | bench_unique_on_1k | 2 | 3 | 114.294mb +0.00% | 188.737ms -1.90% | ±1.15% +26.88% |
| TypeDetectorBench | bench_type_detector | 1 | 3 | 43.802mb +0.00% | 368.604ms +1.02% | ±1.40% +75.95% |
| TypeDetectorBench | bench_type_detector | 1 | 3 | 11.612mb +0.01% | 72.573ms -0.80% | ±0.88% -26.32% |
+-------------------+----------------------------+------+-----+------------------+------------------+-----------------+
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 1.x #1453 +/- ##
==========================================
+ Coverage 83.01% 83.03% +0.01%
==========================================
Files 662 663 +1
Lines 17825 17842 +17
==========================================
+ Hits 14798 14815 +17
Misses 3027 3027
|
|
Test throwing error about string method kebab(), cause it's avaliable on symfony 7.2+ |
|
|
||
| final class StringStyle extends ScalarFunctionChain implements TypedScalarFunction | ||
| { | ||
| public function __construct(private readonly ScalarFunction|string $string, private readonly StringStyles $style) |
There was a problem hiding this comment.
this should be a ScalarFunction|string|StringStyles so you can use it like this:
ref()->stringStyle('snake')
ref()->stringStyle(StringStyles::SNAKE)
ref()->stringStyle(ref('style'))
So if you look at So all we need to do is at the level of StringStyles, check if |
…s parameter Check if kebab() method is avaliable and return it if yes and replace the method if no
…s parameter Use method kebab or snake->replace depends on symfony version
| $string = (new Parameter($this->string))->asString($row); | ||
| $style = (new Parameter($this->style))->as($row, type_string(), type_enum(StringStyles::class)); | ||
|
|
||
| if ($string === null) { |
There was a problem hiding this comment.
you also need to check if style is not null here
…' into integration/symfony-string-camel
Change Log
Added
Fixed
Changed
Removed
Deprecated
Security
Description
Ref: #1316
The StringStyle function has been added to the codebase with an implemented test to ensure functionality. It has been integrated into the ScalarFunctionChain, enabling its use within the chain of scalar functions. Working with StringStyle enum's.