Completed
Push — master ( fb692e...c26f50 )
by ignace nyamagana
03:48
created

Scheme::__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 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
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\Scheme as SchemeInterface;
16
17
/**
18
 * Value object representing a URI scheme component.
19
 *
20
 * @package League.uri
21
 * @author  Ignace Nyamagana Butera <[email protected]>
22
 * @since   1.0.0
23
 */
24
class Scheme extends AbstractComponent implements SchemeInterface
25
{
26
    /**
27
     * @inheritdoc
28
     */
29 778
    protected function validate($scheme)
30
    {
31 778
        if (null === $scheme) {
32 279
            return $scheme;
33
        }
34
35 730
        $scheme = $this->validateString($scheme);
36 718
        if (!preg_match(',^[a-z]([-a-z0-9+.]+)?$,i', $scheme)) {
37 9
            throw new InvalidArgumentException(sprintf("Invalid Submitted scheme: '%s'", $scheme));
38
        }
39
40 709
        return strtolower($scheme);
41
    }
42
43
    /**
44
     * Returns the instance string representation
45
     * with its optional URI delimiters
46
     *
47
     * @return string
48
     */
49 458
    public function getUriComponent()
50
    {
51 458
        $component = $this->__toString();
52 458
        if ('' !== $component) {
53 329
            $component .= SchemeInterface::DELIMITER;
54 219
        }
55
56 458
        return $component;
57
    }
58
}
59