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

HttpDataValidation::isField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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
}