Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 1.31 KB

explode_transformer.md

File metadata and controls

54 lines (40 loc) · 1.31 KB

ExplodeTransformer

Split a string into an array, using PHP's explode function.

Transformer reference

  • Service: CleverAge\ProcessBundle\Transformer\String\ExplodeTransformer
  • Transformer code: explode

Accepted inputs

string, or a scalar or a \Stringable cast to a string. null gives null. An array or another object (a \BackedEnum included) throws an UnexpectedValueException.

Possible outputs

  • array: the list of parts; an empty array for an empty string
  • null if the input is null

Options

Code Type Required Default Description
delimiter string X The boundary string, must not be empty (checked with the configuration)

Examples

  • 'a,b,c' becomes ['a', 'b', 'c']
# Transformer options level
explode:
  delimiter: ','
  • Split then trim each part: 'a, b ,c' becomes ['a', 'b', 'c']
# Transformer mapping level
tags:
  code: '[tags]'
  transformers:
    explode:
      delimiter: ','
    array_map:
      transformers:
        trim: ~