Completed
Push — master ( 93f504...996b1b )
by ignace nyamagana
03:50
created

Port::__debugInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 3
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * League.Uri (http://uri.thephpleague.com)
4
 *
5
 * @package   League.uri
6
 * @author    Ignace Nyamagana Butera <[email protected]>
7
 * @copyright 2013-2015 Ignace Nyamagana Butera
8
 * @license   https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
9
 * @version   4.2.0
10
 * @link      https://github.com/thephpleague/uri/
11
 */
12
namespace League\Uri\Components;
13
14
use InvalidArgumentException;
15
use League\Uri\Interfaces\Port as PortInterface;
16
17
/**
18
 * Value object representing a URI port component.
19
 *
20
 * @package League.uri
21
 * @author  Ignace Nyamagana Butera <[email protected]>
22
 * @since   1.0.0
23
 */
24
class Port extends AbstractComponent implements PortInterface
25
{
26
    /**
27
     * @inheritdoc
28
     */
29 823
    protected function validate($data)
30
    {
31 823
        if ('' === $data) {
32 3
            throw new InvalidArgumentException('Expected port to be a int or null; received an empty string');
33
        }
34
35 820
        return $this->validatePort($data);
36
    }
37
38
    /**
39
     * DEPRECATION WARNING! This method will be removed in the next major point release
40
     *
41
     * @deprecated deprecated since version 4.2
42
     *
43
     * Return an integer representation of the Port component
44
     *
45
     * @return int|null
46
     */
47
    public function toInt()
48
    {
49
        return $this->getContent();
50
    }
51
52
    /**
53
     * @inheritdoc
54
     */
55 2
    public function __debugInfo()
56
    {
57 2
        return ['port' => $this->getContent()];
58
    }
59
60
    /**
61
     * Returns the instance string representation
62
     * with its optional URI delimiters
63
     *
64
     * @return string
65
     */
66 155
    public function getUriComponent()
67
    {
68 155
        $component = $this->__toString();
69 155
        if ('' !== $component) {
70 152
            return PortInterface::DELIMITER.$component;
71
        }
72
73 3
        return $component;
74
    }
75
}
76