Completed
Push — master ( aeb3a4...04afb5 )
by brian
01:57
created

Tokens   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 0

Test Coverage

Coverage 100%
Metric Value
wmc 3
cbo 0
dl 0
loc 42
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A isSeparator() 0 10 3
1
<?php
2
3
/**
4
 * @copyright   (c) 2006-present brian ridley
5
 * @author      brian ridley <[email protected]>
6
 * @license     http://opensource.org/licenses/MIT MIT
7
 */
8
9
namespace ptlis\ConNeg\Parser;
10
11
/**
12
 * Class constants used for tokenization.
13
 */
14
class Tokens
15
{
16
    /**
17
     * Token that indicates the boundary between variant data
18
     */
19
    const VARIANT_SEPARATOR = ',';
20
21
    /**
22
     * Token that indicates the boundary between the variant & any params attached to it.
23
     */
24
    const PARAMS_SEPARATOR = ';';
25
26
    /**
27
     * Token that splits the mime type & subtypes.
28
     */
29
    const MIME_SEPARATOR = '/';
30
31
    /**
32
     * Token that splits params into keys and values.
33
     */
34
    const PARAMS_KV_SEPARATOR = '=';
35
36
37
    /**
38
     * Return true if the provided string is one of the separator tokens defined in this class.
39
     *
40
     * @param string $string
41
     * @param bool $mimeField
42
     *
43
     * @return bool
44
     */
45 80
    public static function isSeparator($string, $mimeField)
46
    {
47
        $separatorList = array(
48 80
            self::VARIANT_SEPARATOR,
49 80
            self::PARAMS_SEPARATOR,
50
            self::PARAMS_KV_SEPARATOR
51 80
        );
52
53 80
        return in_array($string, $separatorList) || ($mimeField && Tokens::MIME_SEPARATOR === $string);
54
    }
55
}
56