Completed
Push — master ( 039dcf...417ea8 )
by Maik
03:08
created

EndpointParser::parseUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
/**
4
 * This file is part of the PHP Generics package.
5
 *
6
 * @package Generics
7
 */
8
namespace Generics\Util;
9
10
use Generics\Socket\Endpoint;
11
use Generics\Socket\InvalidUrlException;
12
13
/**
14
 * This class provides a parser to retrieve Endpoint objects out of arbitrary URIs
15
 *
16
 * @author Maik Greubel <[email protected]>
17
 */
18
class EndpointParser
19
{
20
21
    /**
22
     * Parse a URI into a Endpoint
23
     *
24
     * @param string $url
25
     * @throws InvalidUrlException
26
     * @return \Generics\Socket\Endpoint
27
     */
28 2
    public static function parseUrl($url): Endpoint
29
    {
30 2
        $url = UrlParser::parseUrl($url);
31
        
32 1
        return new Endpoint($url->getAddress(), $url->getPort());
33
    }
34
}
35