Programming Language PHP

Namespace Oro\Component\PhpUtils

Class QueryStringUtil

Method/Function buildQueryString

Total Examples 5

5 code examples of PHP Oro\Component\PhpUtils\QueryStringUtil::buildQueryString extracted from open source projects

Was this example useful?
0
                                                    public function testBuildQueryStringWithObjectParameterValue()
    {
        $this->expectException(\UnexpectedValueException::class);
        $this->expectExceptionMessage('Expected string value for the parameter "prm1", given "stdClass".');

        QueryStringUtil::buildQueryString(['prm1' => new \stdClass()]);
    }
                                            
Was this example useful?
0
                                                    public function testBuildQueryStringWithArrayParameterValue()
    {
        $this->expectException(\UnexpectedValueException::class);
        $this->expectExceptionMessage('Expected string value for the parameter "prm1", given "array".');

        QueryStringUtil::buildQueryString(['prm1' => []]);
    }
                                            
Was this example useful?
0
                                                    public function testBuildQueryStringWithNotStringScalarParameterValue()
    {
        $this->expectException(\UnexpectedValueException::class);
        $this->expectExceptionMessage('Expected string value for the parameter "prm1", given "integer".');

        QueryStringUtil::buildQueryString(['prm1' => 0]);
    }
                                            
Was this example useful?
0
                                                    public function testBuildQueryStringWithNullParameterValue()
    {
        $this->expectException(\UnexpectedValueException::class);
        $this->expectExceptionMessage('Expected string value for the parameter "prm1", given "NULL".');

        QueryStringUtil::buildQueryString(['prm1' => null]);
    }
                                            
Was this example useful?
0
                                                    /**
     * @inheritdoc
     */
    public function getQueryString(): string
    {
        $this->ensureInitialized();

        $params = [];
        foreach ($this->groups as $group => $items) {
            /** @var FilterValue $item */
            foreach ($items as $item) {
                if (!$item->getSourceKey()) {
                    continue;
                }

                $path = $item->getPath();
                if ($path !== $group) {
                    $path = $group . '[' . implode('][', explode('.', $path)) . ']';
                }
                $operator = $item->getOperator();
                if ('eq' !== $operator) {
                    $path .= '[' . $operator . ']';
                }
                $params[$path] = $item->getSourceValue();
            }
        }

        return QueryStringUtil::buildQueryString($params);
    }
                                            
QueryStringUtil's Other Methods