Create a url instance given an array of url properties and values

@param array $arr
@return \sndsgd\Url
6161
public static function createFromArray(array $arr)
    {
        $ret = new Url;
        $keys = ['scheme','user','pass','host','port','path','query','fragment'];
        foreach ($keys as $key) {
            if (array_key_exists($key, $arr)) {
                $fn = 'set'.ucfirst($key);
                call_user_func([$ret, $fn], $arr[$key]);
            }
        }
        return $ret;
    }
227518
public function createUrl($uri = '/')
    {
        if (!isset($this->urlBase)) {
            $ssl = $this->isSSL();
            $protocol = 'http' . (($ssl) ? 's' : '');

            $host = $this->host;
            if (strpos($host, ':') === false) {
                $port = $this->serverData['SERVER_PORT'];
                $port = ((!$ssl && $port == '80') || ($ssl && $port == '443')) ? '' : ':' . $port;
                $host = $this->host . $port;
            }

            $this->urlBase = $protocol . '://' . $host;
        }

        if ($uri !== '' && strpos($uri, '/') === false) {
            $uri = '/' . $uri;
        }

        return $this->urlBase . $uri;
    }
341555
public static function merge2D(array $arr) {
		$args = func_get_args();
		$results = call_user_func_array('array_merge', $args);
		foreach ($results as $key => $value) {
			$temps = array();
			foreach ($args as $val) {
				$temps[] = isset($val[$key]) ? (array)$val[$key] : array();
			}
			$results[$key] = call_user_func_array('array_merge', $temps);
		}
		return $results;
	}
470483
public function url( array $args = [] ) {
		$url = get_permalink( $this->ID );
		if ( $args ) {
			$url = add_query_arg( $args, $url );
		}

		return $url;

	}
1292738
public function buildUrl($url, array $query)
	{
		if (empty($query)) {
			return $url;
		}

		$parts = parse_url($url);

		$queryString = '';
		if (isset($parts['query']) && $parts['query']) {
			$queryString .= $parts['query'].'&'.http_build_query($query);
		} else {
			$queryString .= http_build_query($query);
		}

		$retUrl = $parts['scheme'].'://'.$parts['host'];
		if (isset($parts['port'])) {
			$retUrl .= ':'.$parts['port'];
		}

		if (isset($parts['path'])) {
			$retUrl .= $parts['path'];
		}

		if ($queryString) {
			$retUrl .= '?' . $queryString;
		}

		return $retUrl;
	}
213062
public function customize(array $arr): array
  {
    $res = [];
    if ( isset($arr[0]) ){
      foreach ( $arr as $a ){
        if ( isset($a['id']) && $this->has($a['id']) ){
          $res[] = $a;
        }
      }
    }
    else if ( isset($arr['items']) ){
      $res = $arr;
      unset($res['items']);
      foreach ( $arr['items'] as $a ){
        if ( isset($a['id']) && $this->has($a['id']) ){
          if ( !isset($res['items']) ){
            $res['items'] = [];
          }
          $res['items'][] = $a;
        }
      }
    }
    return $res;
  }
782431
public static function flatten($arr) {
		if(!is_array($arr))
			return [$arr];
		$res = [];
		foreach($arr as $k=>$v) {
			if(is_array($v))
				$res = array_merge($res, static::flatten($v));
			else
				$res[] = $v;
		}
		return $res;
	}
41852
public function url( array $args = []) {
        $url = get_comments_link( $this->post_ID );
        if ( $args ) {
            $url = add_query_arg( $args, $url );
        }

        return $url;
    }
67171
public function parseUrl(array $server) {
        $protocol = array_has($server, 'HTTPS') ? 'https' : 'http';
        $host = array_get($server, 'HTTP_HOST');
        $uri = array_get($server, 'REQUEST_URI');

        return new Url(s('%s://%s%s', $protocol, $host, $uri));
    }
858527
public function create($postArr)
    {
        $userId = null;
        if (Auth::check()) {
            $userId = Auth::user()->id;
        }

        $default = [
            'post_author'    => $userId,
            'post_content'   => '',
            'post_title'     => '',
            'post_excerpt'   => '',
            'post_status'    => 'draft',
            'post_type'      => 'post',
            'comment_status' => '',
            'post_parent'    => 0,
            'menu_order'     => 0,
        ];

        $postArr = array_unique(array_merge($default, $postArr));

        $postArr[ 'guid' ] = sha1(time());

        if (empty($postArr[ 'post_title' ])) {
            return new EtherError('Post title must be provided');
        }

        if (isset($postArr[ 'post_slug' ]) && ! empty($postArr[ 'post_slug' ])) {
            $postArr[ 'post_slug' ] = $this->postRepository->sluggable($postArr[ 'post_slug' ], 'post_slug');
        } else {
            $postArr[ 'post_slug' ] = $this->postRepository->sluggable($postArr[ 'post_title' ], 'post_slug');
        }
        try {
            $post = $this->postRepository->create($postArr);
        } catch (\Exception $e) {
            return new EtherError($e);
        }

        return $post;
    }
1235569
public static function buildUrl($url) {
		if (!is_array($url)) {
			return $url;
		}

		foreach (self::$_urlNotations as $part => $rules) {
			if (array_key_exists($part, $url)) {
				$url[$part] = @$rules['before'] . $url[$part] . @$rules['after'];
			}
		}

		return array_reduce($url,  function($return, $item) {
			$return .= $item;

			return $return;
		});
	}
851140
final private function referencedArgs(&$arr)
    {
        if (strnatcmp(phpversion(), '5.3') >= 0) { //Reference is required for PHP 5.3+
            $refs = array();
            foreach ($arr as $key => $value)
                $refs[] = &$arr[$key];
            return $refs;
        }

        return $arr;
    }
858202
public static function &create($nodeName, $arr = array())
        {
            $xml = self::getXmlRoot();
            $xml->appendChild(self::convert($nodeName, $arr));

            self::$xml = null;    // clear the xml node in the class for 2nd time use.

            return $xml;
        }
104036
public function create(array $ir)
    {
        if (!isset($ir['cast'])) {
            return $this->createRealType(
                isset($ir['data-type']) ? $ir['data-type'] : Types::T_UNDEFINED,
                $ir
            );
        }

        return $this->createCastHint(
            isset($ir['cast']['type']) ? $ir['cast']['type'] : Types::T_UNDEFINED,
            $ir
        );
    }
326976
protected function prepareTree(array $arr) {
        $tree = [];
        foreach ($arr as $a) {
            $name = $a->getName();
            $cur = &$tree;
            foreach (explode("-", $name) as $e) {
                if (empty($cur[$e])) $cur[$e] = [];
                $cur = &$cur[$e];
            }
        }
        return $tree;
    }
83216
protected function buildUrl(array $arguments)
    {
        $url = strtr($this->builders['pattern'], $this->buildUrlRequirements($arguments));
        $url = str_replace('//', '/', $url);

        $query = array_filter($arguments);
        if (!empty($query)) {
            $url .= '?' . http_build_query($query, null, '&');
        }

        $url = ltrim($url, './');

        return $url;
    }
913658
public function shuffle($arr)
  {
    $new = $arr;
    for ($i = count($new) - 1; $i > 0; $i--)
    {
        $j = $this->getNext(0,$i);
        $tmp = $new[$i];
        $new[$i] = $new[$j];
        $new[$j] = $tmp;
    }
    return $new;
  }