Return a formatted string, using PHP's vsprintf function.
- Service:
CleverAge\ProcessBundle\Transformer\String\SprintfTransformer - Transformer code:
sprintf
array: each element is used as an argument of the format, in order- any other value (scalar,
null,\Stringable): used as the single argument of the format
string
| Code | Type | Required | Default | Description |
|---|---|---|---|---|
format |
string |
'%s' |
The format string; see Notes for % |
'bar'becomes'foo bar'
# Transformer options level
sprintf:
format: 'foo %%s'- Format one value
# Transformer mapping level
sprintf_one:
code: '[id]'
transformers:
sprintf:
format: 'one/%%d'- Format several values
# Transformer mapping level
sprintf_multiple:
code:
- '[firstname]'
- '[lastname]'
transformers:
sprintf:
format: 'multiple/%%s/%%s'In Symfony YAML configuration files, % is used for container parameters: escape it as %% ('%%s' is resolved as
'%s'). A format with more placeholders than arguments throws a \ValueError.