HttpDataValidation::isField()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

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