Completed
Push — master ( 98b500...211af5 )
by Derek
03:45
created

UserInfo::compileValidPattern()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 9
loc 9
ccs 8
cts 8
cp 1
rs 9.6666
cc 1
eloc 7
nc 1
nop 0
crap 1
1
<?php
2
namespace Subreality\Dilmun\Anshar\Http\UriParts;
3
4
/**
5
 * Class UserInfo
6
 * @package Subreality\Dilmun\Anshar\Http\UriParts
7
 */
8
class UserInfo extends AbstractUriPart
9
{
10
    protected $unencoded_characters = array(":");
11
    protected $compositions         = array(
12
        "unreserved_characters",
13
        "sub_delims_characters",
14
    );
15
16
    /**
17
     * UserInfo constructor. Accepts a string representing a URI user info component. Construction will throw an
18
     * exception if the user info is not a string.
19
     *
20
     * Construction accepts strings that have been percent-encoded as well as strings that have not been percent-encoded
21
     * and will encode invalid characters.
22
     *
23
     * Construction with a string that includes both encoded and decoded characters will be assumed to be an encoded
24
     * string, resulting in double-encoding.
25
     *
26
     * userinfo    = *( unreserved / pct-encoded / sub-delims / ":" )
27
     * unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"
28
     * pct-encoded = "%" HEXDIG HEXDIG
29
     * sub-delims  = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
30
     *
31
     * @see https://tools.ietf.org/html/rfc3986#appendix-A
32
     *
33
     * @throws \InvalidArgumentException
34
     *
35
     * @param string $user_info     A string representing a URI fragment
36
     */
37 12
    public function __construct($user_info)
38
    {
39 12
        parent::__construct($user_info, "User info");
40 6
    }
41
}
42