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

HttpDataValidation   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isField() 0 4 1
A checkHeaderOrRaiseError() 0 6 4
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
}