Test Failed
Push — master ( 9400f7...aee647 )
by Jairo
02:19
created

HttpDataValidation::checkHeaderOrRaiseError()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.2
c 0
b 0
f 0
cc 4
eloc 3
nc 2
nop 3
1
<?php
2
/**
3
 * Author: bfunky
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
    public static function isField(string $httpLine)
18
    {
19
        return (strpos($httpLine, ':') !== false);
20
    }
21
22
    /**
23
     * @param string $method
24
     * @param string $path
25
     * @param string $protocol
26
     * @throws HttpParserBadFormatException
27
     */
28
    public static function checkHeaderOrRaiseError(string $method, string $path, string $protocol)
29
    {
30
        if (empty($method) || empty($path) || empty($protocol)) {
31
            throw new HttpParserBadFormatException();
32
        }
33
    }
34
}