Whitespace   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 27
ccs 8
cts 8
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A tokenize() 0 7 1
A concatenateDoubleOrMoreSpaces() 0 4 1
A removeStartingAndEndingSpaces() 0 4 1
1
<?php
2
/**
3
 * Copyright (c) 2016 Martin Dilling-Hansen <[email protected]>
4
 * https://github.com/scripturadesign/tokenizer
5
 */
6
7
namespace Scriptura\Tokenizer\Tokenizers;
8
9
use Scriptura\Tokenizer\Tokenizer;
10
11
class Whitespace implements Tokenizer
12
{
13
    /**
14
     * Get the token sequence from a character sequence
15
     *
16
     * @param string $string
17
     *
18
     * @return array
19
     */
20 3
    public function tokenize($string)
21
    {
22 3
        $string = $this->concatenateDoubleOrMoreSpaces($string);
23 3
        $string = $this->removeStartingAndEndingSpaces($string);
24
25 3
        return explode(' ', $string);
26
    }
27
28 3
    protected function concatenateDoubleOrMoreSpaces($string)
29
    {
30 3
        return preg_replace('/  +/', ' ', $string);
31
    }
32
33 3
    protected function removeStartingAndEndingSpaces($string)
34
    {
35 3
        return trim($string);
36
    }
37
}
38