protected function expandStringProperties(
        $data,
        $parent_keys,
        $reference_data,
        $value,
        $key
    ) {
        // We loop through all placeholders in a given string.
        // E.g., '${placeholder1} ${placeholder2}' requires two replacements.
        while (strpos($value, '${') !== false) {
            $original_value = $value;
            $value = preg_replace_callback(
                '/\$\{([^\$}]+)\}/',
                function ($matches) use ($data, $reference_data) {
                    return $this->expandStringPropertiesCallback(
                        $matches,
                        $data,
                        $reference_data
                    );
                },
                $value
            );

            // If no replacement occurred at all, break to prevent
            // infinite loop.
            if ($original_value == $value) {
                break;
            }

            // Set value on $data object.
            if ($parent_keys) {
                $full_key = $parent_keys . "$key";
            } else {
                $full_key = $key;
            }
            $data->set($full_key, $value);
        }
        return $value;
    }