Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\FunctionFixtureReferenceParser::parse PHP Method

parse() public method

public parse ( string $value )
$value string
    public function parse(string $value)
    {
        $parsedValue = $this->parser->parse($value);
        if (false === $parsedValue instanceof ListValue) {
            return $parsedValue;
        }
        $mergedValues = array_reduce($parsedValue->getValue(), [$this, 'mergeFunctionFixtureReferences'], $initial = []);
        return 1 === count($mergedValues) ? $mergedValues[0] : new ListValue($mergedValues);
    }

Usage Example

 /**
  * @dataProvider provideOneElementValues
  */
 public function testIfThereIsOnlyOneElementThenReturnTheElementInsteadOfAValueList($value, $expected)
 {
     $decoratedParserProphecy = $this->prophesize(ParserInterface::class);
     $decoratedParserProphecy->parse(Argument::any())->willReturn($expected);
     /** @var ParserInterface $decoratedParser */
     $decoratedParser = $decoratedParserProphecy->reveal();
     $parser = new FunctionFixtureReferenceParser($decoratedParser);
     $actual = $parser->parse('');
     $this->assertEquals($expected, $actual);
 }