Domain::specifyType()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
3
namespace ValueObjects\Web;
4
5
use ValueObjects\StringLiteral\StringLiteral;
6
7
abstract class Domain extends StringLiteral
8
{
9
    /**
10
     * Returns a Hostname or a IPAddress object depending on passed value
11
     *
12
     * @param $domain
13
     * @return Hostname|IPAddress
14
     */
15 4
    public static function specifyType($domain)
16
    {
17 4
        if (false !== filter_var($domain, FILTER_VALIDATE_IP)) {
18 1
            return new IPAddress($domain);
19
        }
20
21 4
        return new Hostname($domain);
22
    }
23
}
24