Test Failed
Push — master ( 3e9160...6b5548 )
by Jairo
02:47
created

HttpDataValidation::isField()   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 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * Author: jairo.rodriguez <[email protected]>
4
 */
5
6
namespace BFunky\HttpParser\Entity;
7
8
9
use BFunky\HttpParser\Exception\HttpParserBadFormatException;
10
11
class HttpDataValidation
12
{
13
    /**
14
     * @param string $httpLine
15
     * @return bool
16
     */
17 4
    public static function isField(string $httpLine): bool
18
    {
19 4
        return (strpos($httpLine, ':') !== false);
20
    }
21
22
    /**
23
     * @param string $method
24
     * @param string $path
25
     * @param string $protocol
26
     * @throws HttpParserBadFormatException
27
     */
28 3
    public static function checkHeaderOrRaiseError(string $method, string $path, string $protocol): void
29
    {
30 3
        if (empty($method) || empty($path) || empty($protocol)) {
31 3
            throw new HttpParserBadFormatException();
32
        }
33
    }
34
}