resolveString example

$args[$resolvedKey] = $this->resolveValue($v$resolving);
            }

            return $args;
        }

        if (!\is_string($value) || '' === $value || !str_contains($value, '%')) {
            return $value;
        }

        return $this->resolveString($value$resolving);
    }

    /** * Resolves parameters inside a string. * * @param array $resolving An array of keys that are being resolved (used internally to detect circular references) * * @throws ParameterNotFoundException if a placeholder references a parameter that does not exist * @throws ParameterCircularReferenceException if a circular reference if detected * @throws RuntimeException when a given parameter has a type problem */
    
$this->assertEquals(['bar' => ['ding' => 'I\'m a bar %%foo %%bar', 'zero' => null]]$bag->get('foo'), '->escapeValue() escapes % by doubling it');
    }

    /** * @dataProvider stringsWithSpacesProvider */
    public function testResolveStringWithSpacesReturnsString($expected$test$description)
    {
        $bag = new ParameterBag(['foo' => 'bar']);

        try {
            $this->assertEquals($expected$bag->resolveString($test)$description);
        } catch (ParameterNotFoundException $e) {
            $this->fail(sprintf('%s - "%s"', $description$expected));
        }
    }

    public static function stringsWithSpacesProvider()
    {
        return [
            ['bar', '%foo%', 'Parameters must be wrapped by %.'],
            ['% foo %', '% foo %', 'Parameters should not have spaces.'],
            ['{% set my_template = "foo" %}', '{% set my_template = "foo" %}', 'Twig-like strings are not parameters.'],
            [
$args[$resolvedKey] = $this->resolveValue($v$resolving);
            }

            return $args;
        }

        if (!\is_string($value) || 2 > \strlen($value)) {
            return $value;
        }

        return $this->resolveString($value$resolving);
    }

    /** * Resolves parameters inside a string. * * @param array $resolving An array of keys that are being resolved (used internally to detect circular references) * * @throws ParameterNotFoundException if a placeholder references a parameter that does not exist * @throws ParameterCircularReferenceException if a circular reference if detected * @throws RuntimeException when a given parameter has a type problem */
    
Home | Imprint | This part of the site doesn't use cookies.