Completed
Push — master ( 24da9e...18bd75 )
by Josh
05:16
created

AbstractDiff::getMatchThreshold()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Caxy\HtmlDiff;
4
5
abstract class AbstractDiff
6
{
7
    public static $defaultSpecialCaseTags = array('strong', 'b', 'i', 'big', 'small', 'u', 'sub', 'sup', 'strike', 's', 'p');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
8
    public static $defaultSpecialCaseChars = array('.', ',', '(', ')', '\'');
9
    public static $defaultGroupDiffs = true;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
10
11
    protected $content;
12
    protected $oldText;
13
    protected $newText;
14
    protected $oldWords = array();
15
    protected $newWords = array();
16
    protected $encoding;
17
    protected $specialCaseOpeningTags = array();
18
    protected $specialCaseClosingTags = array();
19
    protected $specialCaseTags;
20
    protected $specialCaseChars;
21
    protected $groupDiffs;
22
    protected $matchThreshold = 80;
23
24
    public function __construct($oldText, $newText, $encoding = 'UTF-8', $specialCaseTags = null, $groupDiffs = null)
25
    {
26
        if ($specialCaseTags === null) {
27
            $specialCaseTags = static::$defaultSpecialCaseTags;
28
        }
29
30
        if ($groupDiffs === null) {
31
            $groupDiffs = static::$defaultGroupDiffs;
32
        }
33
34
        $this->oldText = $this->purifyHtml(trim($oldText));
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
35
        $this->newText = $this->purifyHtml(trim($newText));
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
36
        $this->encoding = $encoding;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
37
        $this->content = '';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
38
        $this->groupDiffs = $groupDiffs;
39
        $this->setSpecialCaseTags($specialCaseTags);
40
        $this->setSpecialCaseChars(static::$defaultSpecialCaseChars);
41
    }
42
43
    /**
44
     * @return int
45
     */
46
    public function getMatchThreshold()
47
    {
48
        return $this->matchThreshold;
49
    }
50
51
    /**
52
     * @param int $matchThreshold
53
     *
54
     * @return AbstractDiff
55
     */
56
    public function setMatchThreshold($matchThreshold)
57
    {
58
        $this->matchThreshold = $matchThreshold;
59
60
        return $this;
61
    }
62
63
64
65
    public function setSpecialCaseChars(array $chars)
66
    {
67
        $this->specialCaseChars = $chars;
68
    }
69
70
    public function getSpecialCaseChars()
71
    {
72
        return $this->specialCaseChars;
73
    }
74
75
    public function addSpecialCaseChar($char)
76
    {
77
        if (!in_array($char, $this->specialCaseChars)) {
78
            $this->specialCaseChars[] = $char;
79
        }
80
    }
81
82
    public function removeSpecialCaseChar($char)
83
    {
84
        $key = array_search($char, $this->specialCaseChars);
85
        if ($key !== false) {
86
            unset($this->specialCaseChars[$key]);
87
        }
88
    }
89
90
    public function setSpecialCaseTags(array $tags = array())
91
    {
92
        $this->specialCaseTags = $tags;
93
94
        foreach ($this->specialCaseTags as $tag) {
95
            $this->addSpecialCaseTag($tag);
96
        }
97
    }
98
99
    public function addSpecialCaseTag($tag)
100
    {
101
        if (!in_array($tag, $this->specialCaseTags)) {
102
            $this->specialCaseTags[] = $tag;
103
        }
104
105
        $opening = $this->getOpeningTag($tag);
106
        $closing = $this->getClosingTag($tag);
107
108
        if (!in_array($opening, $this->specialCaseOpeningTags)) {
109
            $this->specialCaseOpeningTags[] = $opening;
110
        }
111
        if (!in_array($closing, $this->specialCaseClosingTags)) {
112
            $this->specialCaseClosingTags[] = $closing;
113
        }
114
    }
115
116
    public function removeSpecialCaseTag($tag)
117
    {
118
        if (($key = array_search($tag, $this->specialCaseTags)) !== false) {
119
            unset($this->specialCaseTags[$key]);
120
121
            $opening = $this->getOpeningTag($tag);
122
            $closing = $this->getClosingTag($tag);
123
124
            if (($key = array_search($opening, $this->specialCaseOpeningTags)) !== false) {
125
                unset($this->specialCaseOpeningTags[$key]);
126
            }
127
            if (($key = array_search($closing, $this->specialCaseClosingTags)) !== false) {
128
                unset($this->specialCaseClosingTags[$key]);
129
            }
130
        }
131
    }
132
133
    public function getSpecialCaseTags()
134
    {
135
        return $this->specialCaseTags;
136
    }
137
138
    public function getOldHtml()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
139
    {
140
        return $this->oldText;
141
    }
142
143
    public function getNewHtml()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
144
    {
145
        return $this->newText;
146
    }
147
148
    public function getDifference()
149
    {
150
        return $this->content;
151
    }
152
153
    public function setGroupDiffs($boolean)
154
    {
155
        $this->groupDiffs = $boolean;
156
    }
157
158
    public function isGroupDiffs()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
159
    {
160
        return $this->groupDiffs;
161
    }
162
163
    protected function getOpeningTag($tag)
164
    {
165
        return "/<".$tag."[^>]*/i";
166
    }
167
168
    protected function getClosingTag($tag)
169
    {
170
        return "</".$tag.">";
171
    }
172
173
    protected function getStringBetween($str, $start, $end)
174
    {
175
        $expStr = explode( $start, $str, 2 );
176
        if ( count( $expStr ) > 1 ) {
177
            $expStr = explode( $end, $expStr[ 1 ] );
178
            if ( count( $expStr ) > 1 ) {
179
                array_pop( $expStr );
180
181
                return implode( $end, $expStr );
182
            }
183
        }
184
185
        return '';
186
    }
187
188
    protected function purifyHtml($html, $tags = null)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
Unused Code introduced by
The parameter $tags is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
189
    {
190
        if ( class_exists( 'Tidy' ) && false ) {
191
            $config = array( 'output-xhtml'   => true, 'indent' => false );
192
            $tidy = new tidy();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
193
            $tidy->parseString( $html, $config, 'utf8' );
194
            $html = (string) $tidy;
195
196
            return $this->getStringBetween( $html, '<body>' );
0 ignored issues
show
Bug introduced by
The call to getStringBetween() misses a required argument $end.

This check looks for function calls that miss required arguments.

Loading history...
197
        }
198
199
        return $html;
200
    }
201
202
    protected function splitInputsToWords()
203
    {
204
        $this->oldWords = $this->convertHtmlToListOfWords( $this->explode( $this->oldText ) );
205
        $this->newWords = $this->convertHtmlToListOfWords( $this->explode( $this->newText ) );
206
    }
207
208
    protected function isPartOfWord($text)
209
    {
210
        return ctype_alnum(str_replace($this->specialCaseChars, '', $text));
211
    }
212
213
    protected function convertHtmlToListOfWords($characterString)
214
    {
215
        $mode = 'character';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
216
        $current_word = '';
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
217
        $words = array();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
218
        foreach ($characterString as $i => $character) {
219
            switch ($mode) {
220
                case 'character':
221
                if ( $this->isStartOfTag( $character ) ) {
222
                    if ($current_word != '') {
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
223
                        $words[] = $current_word;
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
224
                    }
225
                    $current_word = "<";
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
226
                    $mode = 'tag';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
227
                } elseif ( preg_match( "[^\s]", $character ) > 0 ) {
228
                    if ($current_word != '') {
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
229
                        $words[] = $current_word;
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
230
                    }
231
                    $current_word = $character;
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
232
                    $mode = 'whitespace';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
233
                } else {
234
                    if (
235
                        (ctype_alnum($character) && (strlen($current_word) == 0 || $this->isPartOfWord($current_word))) ||
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
236
                        (in_array($character, $this->specialCaseChars) && isset($characterString[$i+1]) && $this->isPartOfWord($characterString[$i+1]))
237
                    ) {
238
                        $current_word .= $character;
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
239
                    } else {
240
                        $words[] = $current_word;
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
241
                        $current_word = $character;
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
242
                    }
243
                }
244
                break;
245
                case 'tag' :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
246
                if ( $this->isEndOfTag( $character ) ) {
247
                    $current_word .= ">";
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
248
                    $words[] = $current_word;
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
249
                    $current_word = "";
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
250
251
                    if ( !preg_match('[^\s]', $character ) ) {
252
                        $mode = 'whitespace';
253
                    } else {
254
                        $mode = 'character';
255
                    }
256
                } else {
257
                    $current_word .= $character;
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
258
                }
259
                break;
260
                case 'whitespace':
261
                if ( $this->isStartOfTag( $character ) ) {
262
                    if ($current_word != '') {
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
263
                        $words[] = $current_word;
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
264
                    }
265
                    $current_word = "<";
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
266
                    $mode = 'tag';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
267
                } elseif ( preg_match( "[^\s]", $character ) ) {
268
                    $current_word .= $character;
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
269
                } else {
270
                    if ($current_word != '') {
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
271
                        $words[] = $current_word;
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
272
                    }
273
                    $current_word = $character;
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
274
                    $mode = 'character';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
275
                }
276
                break;
277
                default:
278
                break;
279
            }
280
        }
281
        if ($current_word != '') {
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
282
            $words[] = $current_word;
0 ignored issues
show
Coding Style introduced by
$current_word does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
283
        }
284
285
        return $words;
286
    }
287
288
    protected function isStartOfTag($val)
289
    {
290
        return $val == "<";
291
    }
292
293
    protected function isEndOfTag($val)
294
    {
295
        return $val == ">";
296
    }
297
298
    protected function isWhiteSpace($value)
299
    {
300
        return !preg_match( '[^\s]', $value );
301
    }
302
303
    protected function explode($value)
304
    {
305
        // as suggested by @onassar
306
        return preg_split( '//u', $value );
307
    }
308
}
309