HttpDataValidation   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 24
ccs 5
cts 6
cp 0.8333
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: Jairo Rodríguez <[email protected]>
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace BFunky\HttpParser\Entity;
10
11
use BFunky\HttpParser\Exception\HttpParserBadFormatException;
12
13
class HttpDataValidation
14
{
15
    /**
16
     * @param string $httpLine
17 4
     * @return bool
18
     */
19 4
    public static function isField(string $httpLine): bool
20
    {
21
        return (strpos($httpLine, ':') !== false);
22
    }
23
24
    /**
25
     * @param string $method
26
     * @param string $path
27
     * @param string $protocol
28 3
     * @throws HttpParserBadFormatException
29
     */
30 3
    public static function checkHeaderOrRaiseError(string $method, string $path, string $protocol): void
31 3
    {
32
        if (empty($method) || empty($path) || empty($protocol)) {
33
            throw new HttpParserBadFormatException();
34
        }
35
    }
36
}