Build.

@param bool $toArray

@return array|Collection|mixed
340625
public function buildData($toArray = true)
    {
        if (empty($this->data)) {
            $collection = $this->get();

            if ($this->collectionCallback) {
                $collection = call_user_func($this->collectionCallback, $collection);
            }

            if ($toArray) {
                $this->data = $collection->toArray();
            } else {
                $this->data = $collection;
            }
        }

        return $this->data;
    }
476763
public function arrayToObject($array)
    {
        $object = new \stdClass();
        foreach ($array as $k => $v) {
            if (is_array($v)) {
                // load nested elements
                $v = $this->arrayToObject($v);
            }
            $object->{$k} = $v;
        }

        return $object;
    }
688095
public function getFilters($to_array = true) {
		if ($to_array === true) {
			return $this->filters->toArray();
		}

		return $this->filters;
	}
791779
public function build(): GetSearchResultsRequest
	{
		$instance = new GetSearchResultsRequest();
		if ($this->searchId === null) {
			throw new BuilderException('Property [searchId] is required.');
		}
		$instance->searchId = $this->searchId;
		if ($this->fromIndex === null) {
			throw new BuilderException('Property [fromIndex] is required.');
		}
		$instance->fromIndex = $this->fromIndex;
		if ($this->toIndex === null) {
			throw new BuilderException('Property [toIndex] is required.');
		}
		$instance->toIndex = $this->toIndex;
		return $instance;
	}
1205421
protected function buildObjectsArray()
    {
        $objects = [];
        foreach ($this->objectConfigurations as $objectConfiguration) {
            $objectName = $objectConfiguration->getObjectName();
            $objects[$objectName] = [
                'l' => strtolower($objectName),
                's' => $objectConfiguration->getScope(),
                'p' => $objectConfiguration->getPackageKey()
            ];
            if ($objectConfiguration->getClassName() !== $objectName) {
                $objects[$objectName]['c'] = $objectConfiguration->getClassName();
            }
            if ($objectConfiguration->getFactoryObjectName() !== '') {
                $objects[$objectName]['f'] = [
                    $objectConfiguration->getFactoryObjectName(),
                    $objectConfiguration->getFactoryMethodName()
                ];

                $objects[$objectName]['fa'] = [];
                $factoryMethodArguments = $objectConfiguration->getArguments();
                if (count($factoryMethodArguments) > 0) {
                    foreach ($factoryMethodArguments as $index => $argument) {
                        $objects[$objectName]['fa'][$index] = [
                            't' => $argument->getType(),
                            'v' => $argument->getValue()
                        ];
                    }
                }
            }
        }
        $this->configurationCache->set('objects', $objects);
        return $objects;
    }
287484
public function mapArray( $array, bool $recursive = false) {
        $handler = $this->_getMapValueHandler();
        $mapper = $recursive ? new RecursiveCallbackMapper($handler) : new CallbackMapper($handler);
        $mapping = new CollectionMapping($mapper);
        return $mapping->mapCollection($array);
    }
706578
public function getQuery($toArray = false)
    {
        if ($toArray) {
            return $this->vars;
        }

        // If the query is empty build it first
        if (is_null($this->query)) {
            $this->query = UriHelper::buildQuery($this->vars);
        }

        return $this->query;
    }
490333
public function buildAttributes($array)
    {
        $output = array();

        if ($array instanceof KObjectConfig) {
            $array = KObjectConfig::unbox($array);
        }

        if (is_array($array))
        {
            foreach ($array as $key => $item)
            {
                if (is_array($item)) {
                    $item = implode(' ', $item);
                }

                if (is_bool($item))
                {
                    if ($item === false) continue;
                    $item = $key;
                }

                $output[] = $key . '="' . str_replace('"', '&quot;', $item) . '"';
            }
        }

        return implode(' ', $output);
    }
635606
public function getPath($toArray = false)
    {
        $result = $toArray ? $this->_path : $this->_pathEncode($this->_path);
        return $result;
    }
922414
public function build(array $elements)
	{
		$parsedElements = $this->parse($elements); 
		$result = $this->group($parsedElements);

        return $result;
	}
783546
public function toArray($force = true)
    {
        if (!$force && !$this->hasChildren()) {
            return $this->toValue();
        }

        $data = array();
        foreach ($this->children() as $name => $child) {
            $data[$name] = $child->toArray(false);
        }

        return $data;
    }
804455
public function toArray($is_numeric_index = true ,$itemToArray = false)
    {

        $array = array();
        foreach ($this->_items as $item) {
            if (!$is_numeric_index) {
                $id = (string) $item->getId();
                if ($itemToArray) {
                    $item = $item->toArray();
                }
                $array[$id] = $item;
            } else {
                if ($itemToArray) {
                    $item = $item->toArray();
                }
                $array[] = $item;
            }
        }

        return $array;

    }
680236
public function __values(bool $to_array = null):array{
		return array_values($to_array === true ? $this->__toArray() : $this->array);
	}
456462
public function build()
    {
        $this->dataObject = array();
        foreach ($this->buildItems['collection'] as $builder) {
            if (!$builder->build()) {
                return false;
            } else {
                $this->dataObject[] = $builder->getResult();
            }
        }

        return true;
    }
432845
public function getQuery($toArray = false)
    {
        $result = $toArray ? $this->_query : http_build_query($this->_query, '', '&');
        return $result;
    }
320456
public static function createFromArray(array $array): self
    {
        $config = new self(
            ($array['language'] ?? null),
            ($array['store_searchable_metadata'] ?? true)
        );

        $config->synonyms = array_map(function (array $synonym) {
            return Synonym::createFromArray($synonym);
        }, $array['synonyms'] ?? []);
        $config->shards = (int) ($array['shards'] ?? self::DEFAULT_SHARDS);
        $config->replicas = (int) ($array['replicas'] ?? self::DEFAULT_REPLICAS);

        return $config;
    }
376803
public function build(array $filters = [])
    {
        $assets = [];
        foreach (array_keys($this->_queued) as $alias) {
            $this->_resolveDependencies($this->_collection->get($alias), $assets);
        }

        /** @var Asset $asset */
        $result = [
            Asset::TYPE_JS_FILE  => [],
            Asset::TYPE_JS_CODE  => [],
            Asset::TYPE_JSX_FILE => [],
            Asset::TYPE_JSX_CODE => [],
            Asset::TYPE_CSS_FILE => [],
            Asset::TYPE_CSS_CODE => [],
            Asset::TYPE_CALLBACK => [],
        ];
        foreach ($assets as $asset) {

            $source = $asset->load($filters);

            if (Asset::TYPE_COLLECTION === $source[0]) {
                $source = $source[1];
            } else {
                $source = [$source];
            }

            foreach ($source as $sourceItem) {

                $type = $sourceItem[0];
                $src = $sourceItem[1];

                if ($src && !Arr::in($src, $result[$type])) {
                    $result[$type][] = $src;
                }
            }
        }

        return $result;
    }