WhiteSpace   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 1 Features 1
Metric Value
wmc 4
c 1
b 1
f 1
lcom 0
cbo 1
dl 0
loc 38
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isWhiteSpace() 0 6 2
A isWhiteSpaceString() 0 4 1
A getWhiteSpaceString() 0 7 1
1
<?php
2
/**
3
 * Author: Nil Portugués Calderó <[email protected]>
4
 * Date: 12/23/14
5
 * Time: 1:19 PM.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace NilPortugues\Sql\QueryFormatter\Tokenizer\Parser;
12
13
use NilPortugues\Sql\QueryFormatter\Tokenizer\Tokenizer;
14
15
/**
16
 * Class WhiteSpace.
17
 */
18
final class WhiteSpace
19
{
20
    /**
21
     * @param Tokenizer $tokenizer
22
     * @param string    $string
23
     * @param array     $matches
24
     */
25
    public static function isWhiteSpace(Tokenizer $tokenizer, $string, array &$matches)
26
    {
27
        if (self::isWhiteSpaceString($string, $matches)) {
28
            $tokenizer->setNextToken(self::getWhiteSpaceString($matches));
29
        }
30
    }
31
32
    /**
33
     * @param string $string
34
     * @param array  $matches
35
     *
36
     * @return bool
37
     */
38
    public static function isWhiteSpaceString($string, array &$matches)
39
    {
40
        return (1 == \preg_match('/^\s+/', $string, $matches));
41
    }
42
43
    /**
44
     * @param array $matches
45
     *
46
     * @return array
47
     */
48
    public static function getWhiteSpaceString(array &$matches)
49
    {
50
        return [
51
            Tokenizer::TOKEN_VALUE => $matches[0],
52
            Tokenizer::TOKEN_TYPE => Tokenizer::TOKEN_TYPE_WHITESPACE,
53
        ];
54
    }
55
}
56