Worker function for toUrl - does not rely on instance state

@param array $data
@return string
421134
protected function toUrlArray($data)
    {
        $url = array_intersect_key($data, $this->uriKeys);

        foreach (['host', 'user', 'pass'] as $key) {
            if (!isset($url[$key])) {
                continue;
            }

            $url[$key] = urlencode($url[$key]);
        }

        if ($url['adapter']) {
            $return = $url['scheme'] . '+' . $url['adapter'] . '://';
        } else {
            $return = $url['scheme'] . '://';
        }

        if (!empty($url['user'])) {
            $return .= $url['user'];
            if (!empty($url['pass'])) {
                $return .= ':' . $url['pass'];
            }
            $return .= '@';
        }

        $return .= $url['host'];

        $defaultPort = $this->defaultPort();
        if (!empty($url['port']) && $url['port'] != $defaultPort) {
            $return .= ':' . $url['port'];
        }
        $return .= $url['path'];

        $query = array_diff_key($data, $this->uriKeys);
        if ($query) {
            foreach ($query as $key => &$value) {
                if (is_array($value)) {
                    $intermediate = [];
                    foreach ($value as $k => $v) {
                        $v = urlencode($v);
                        $intermediate[] = "{$key}[$k]=$v";
                    }
                    $value = implode($intermediate, '&');

                    continue;
                }
                $value = "$key=$value";
            }
            $return .= '?' . implode($query, '&');
        }

        return $return;
    }
456479
public function serializeData($data) {
		if(is_array($data)) {
			ksort($data);
			$return = '';
			foreach($data as $key => $value) {
				if(is_numeric($key)) {
					$return .= $this->serializeData($value);
				} else {
					$return .= $key . $this->serializeData($value);
				}
			}
			return $return;
		} else {
			return (string)$data;
		}
	}
724778
public function createObjectStateListFromData(array $data)
    {
        $objectStates = array();

        foreach ($data as $objectStateData) {
            $objectStates[] = $this->createObjectStateFromData($objectStateData);
        }

        return $objectStates;
    }
1195701
private function replace(array $data): string
    {
        $widget = explode(':', $data[1]);
        if (class_exists($class = $widget[0]) && method_exists($class, $method = $widget[1])) {
            return call_user_func([$class, $method]);
        }

        return '';
    }
247444
function factory(array $data) {
        if(parent::has($data['id'])) {
            $role = parent::get($data['id']);
            $role->_patch($data);
            return $role;
        }
        
        $role = new \CharlotteDunois\Yasmin\Models\Role($this->client, $this->guild, $data);
        $this->set($role->id, $role);
        return $role;
    }
1150362
public function route($data)
    {
        if (is_array($data)) {
            $path = $data[0];
            $pkg = $data[1];
        } else {
            $path = $data;
        }

        $path = trim($path, '/');
        $pkgHandle = null;
        if ($pkg) {
            if (is_object($pkg)) {
                $pkgHandle = $pkg->getPackageHandle();
            } else {
                $pkgHandle = $pkg;
            }
        }

        $route = '/ccm';
        if ($pkgHandle) {
            $route .= "/{$pkgHandle}";
        } else {
            $route .= '/system';
        }

        $route .= "/{$path}";

        return $route;
    }
382846
public function render(array $data = []): string
    {
        $this->addData($data);
        unset($data);
        \extract($this->data, EXTR_OVERWRITE);

        $__level__ = \ob_get_level();

        try {
            \ob_start();
            include $this->template;
            $content = \ob_get_clean();

            if (null !== $this->layoutName) {
                $layout = $this->engine->make($this->layoutName);
                $layout->sections = \array_merge($this->sections, ['content' => $content]);
                $content = $layout->render($this->layoutData);
            }

            return $content;
        } catch (\Throwable $e) {
            while (\ob_get_level() > $__level__) {
                \ob_end_clean();
            }

            throw $e;
        }
    }
104478
protected function cleanFormData(array $data)
    {
        foreach ($data as $key => $value) {
            if (\is_array($value)) {
                $data[$key] = $this->cleanFormData($value);
            } elseif (\is_object($value)) {
                unset($data[$key]);
            }
        }

        return $data;
    }
1051078
public function createObjectStateFromData(array $data)
    {
        $objectState = new ObjectState();

        $languageIds = [(int)$data[0]['ezcobj_state_default_language_id']];
        foreach ($data as $stateTranslation) {
            $languageIds[] = (int)$stateTranslation['ezcobj_state_language_language_id'] & ~1;
        }
        $languages = $this->languageHandler->loadList($languageIds);

        $objectState->id = (int)$data[0]['ezcobj_state_id'];
        $objectState->groupId = (int)$data[0]['ezcobj_state_group_id'];
        $objectState->identifier = $data[0]['ezcobj_state_identifier'];
        $objectState->priority = (int)$data[0]['ezcobj_state_priority'];
        $objectState->defaultLanguage = $languages[(int)$data[0]['ezcobj_state_default_language_id']]->languageCode;

        $objectState->languageCodes = array();
        $objectState->name = array();
        $objectState->description = array();

        foreach ($data as $stateTranslation) {
            $languageCode = $languages[$stateTranslation['ezcobj_state_language_language_id'] & ~1]->languageCode;
            $objectState->languageCodes[] = $languageCode;
            $objectState->name[$languageCode] = $stateTranslation['ezcobj_state_language_name'];
            $objectState->description[$languageCode] = $stateTranslation['ezcobj_state_language_description'];
        }

        return $objectState;
    }
1214620
public static function format(array $data) {
        return array_map(function ($item) {
            $args = static::toArrOrNone($item);
            if (false !== $args) {
                return $args;
            }
            return $item;
        }, $data);
    }
208204
protected static function getFirstRow(array $data)
    {
        if (empty($data)) {
            throw new \InvalidArgumentException('Empty data.');
        }

        list($first) = $data;

        if (!is_array($first)) {
            throw new \InvalidArgumentException('$data is not an array of array.');
        }

        return $first;
    }
238174
protected function _cleanupData(array $data = array())
    {
        $clean = array();

        foreach ($data as $key => $value)
        {
            if (!empty($value)) {
                $clean[$key] = $value;
            }
        }

        return $clean;
    }
1040716
private function generateDefaultLine(array $data): string
    {
        return sprintf('    '.'<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%s</priority></url>'."\n", $data['url'], date('Y-m-d', strtotime($data['lastmod'])), $data['changefreq'], $data['priority']);
    }
434806
public static function calculateHashOfArray(array $data): string
    {
        return self::calculateHash((string) json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
    }
776691
public function run($data)
    {
        if (($data instanceof Eloquent) || ($data instanceof Arrayable)) {
            return $data->toArray();
        } elseif ($data instanceof Renderable) {
            return \e($data->render());
        } elseif (\is_array($data)) {
            return \array_map([$this, 'run'], $data);
        }

        return $data;
    }
51359
public function xssClean(array $data)
    {
        foreach ($data as $k => $v) {
            $data[$k] = filter_var($v, FILTER_SANITIZE_STRING);
        }

        return $data;
    }
1195514
public static function getGeneratorFromParametersData(array $data): string
    {
        assert(array_key_exists(self::KEY_ROUTER_PARAMS__GENERATOR, $data));
        $result = $data[self::KEY_ROUTER_PARAMS__GENERATOR];
        assert(empty($result) === false);
        assert(static::classImplements($result, DataGenerator::class));

        return $result;
    }