Completed
Push — master ( 4de594...21f32b )
by ignace nyamagana
04:46
created

User::validate()   A

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 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2
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 League\Uri\Interfaces\User as UserInterface;
15
16
/**
17
 * Value object representing a URI user component.
18
 *
19
 * @package League.uri
20
 * @author  Ignace Nyamagana Butera <[email protected]>
21
 * @since   1.0.0
22
 */
23
class User extends AbstractComponent implements UserInterface
24
{
25
    /**
26
     * @inheritdoc
27
     */
28 816
    protected function validate($data)
29
    {
30 816
        if (null === $data) {
31 633
            return $data;
32
        }
33
34 234
        return $this->decodeComponent($this->validateString($data));
35
    }
36
37
    /**
38
     * @inheritdoc
39
     */
40 798
    public function __toString()
41
    {
42 798
        return $this->encodeUser((string) $this->data);
43
    }
44
45
    /**
46
     * @inheritdoc
47
     */
48 2
    public function __debugInfo()
49
    {
50 2
        return ['user' => $this->__toString()];
51
    }
52
}
53