src/ImboClient/ImboClient.php
private function parseUrls($urls) {
        $urls = (array) $urls;
        $result = array();
        $counter = 0;

        foreach ($urls as $serverUrl) {
            if (!preg_match('|^https?://|', $serverUrl)) {
                $serverUrl = 'http://' . $serverUrl;
            }

            $parts = parse_url($serverUrl);

            // Remove the port from the server URL if it's equal to 80 when scheme is http, or if
            // it's equal to 443 when the scheme is https
            if (
                isset($parts['port']) && (
                    ($parts['scheme'] === 'http' && $parts['port'] == 80) ||
                    ($parts['scheme'] === 'https' && $parts['port'] == 443)
                )
            ) {
                if (empty($parts['path'])) {
                    $parts['path'] = '';
                }

                $serverUrl = $parts['scheme'] . '://' . $parts['host'] . $parts['path'];
            }

            $serverUrl = rtrim($serverUrl, '/');

            if (!isset($result[$serverUrl])) {
                $result[$serverUrl] = $counter++;
            }
        }

        return array_flip($result);
     }
private function parseUrls($urls) {
        $urls = (array) $urls;
        $result = array();
        $counter = 0;

        foreach ($urls as $serverUrl) {
            if (!preg_match('|^https?://|', $serverUrl)) {
                $serverUrl = 'http://' . $serverUrl;
            }

            $parts = parse_url($serverUrl);

            // Remove the port from the server URL if it's equal to 80 when scheme is http, or if
            // it's equal to 443 when the scheme is https
            if (
                isset($parts['port']) && (
                    ($parts['scheme'] === 'http' && $parts['port'] == 80) ||
                    ($parts['scheme'] === 'https' && $parts['port'] == 443)
                )
            ) {
                if (empty($parts['path'])) {
                    $parts['path'] = '';
                }

                $serverUrl = $parts['scheme'] . '://' . $parts['host'] . $parts['path'];
            }

            $serverUrl = rtrim($serverUrl, '/');

            if (!isset($result[$serverUrl])) {
                $result[$serverUrl] = $counter++;
            }
        }

        return array_flip($result);
     }
private function parseUrls ( $ urls ) { $ urls = ( array ) $ urls ; $ result = array ( ) ; $ counter = 0 ; foreach ( $ urls as $ serverUrl ) { if ( ! preg_match ( '|^https?://|' , $ serverUrl ) ) { $ serverUrl = 'http://' . $ serverUrl ; } $ parts = parse_url ( $ serverUrl ) ; // Remove the port from the server URL if it's equal to 80 when scheme is http, or if // it's equal to 443 when the scheme is https if ( isset ( $ parts [ 'port' ] ) && ( ( $ parts [ 'scheme' ] === 'http' && $ parts [ 'port' ] == 80 ) || ( $ parts [ 'scheme' ] === 'https' && $ parts [ 'port' ] == 443 ) ) ) { if ( empty ( $ parts [ 'path' ] ) ) { $ parts [ 'path' ] = '' ; } $ serverUrl = $ parts [ 'scheme' ] . '://' . $ parts [ 'host' ] . $ parts [ 'path' ] ; } $ serverUrl = rtrim ( $ serverUrl , '/' ) ; if ( ! isset ( $ result [ $ serverUrl ] ) ) { $ result [ $ serverUrl ] = $ counter ++ ; } } return array_flip ( $ result ) ; }
Parse server URLs and prepare them for usage

@param array|string $urls One or more URLs to an Imbo server
@return array Returns an array of URLs
Parse server URLs and prepare them for usage