Completed
Push — master ( 5f9e66...1f3475 )
by mw
123:57 queued 89:01
created

TokenizerTest::textProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace SMW\Tests\Utils;
4
5
use SMW\Utils\Tokenizer;
6
7
/**
8
 * @covers \SMW\Utils\Tokenizer
9
 * @group semantic-mediawiki
10
 *
11
 * @license GNU GPL v2+
12
 * @since 2.5
13
 *
14
 * @author mwjames
15
 */
16
class TokenizerTest extends \PHPUnit_Framework_TestCase {
17
18
	/**
19
	 * @dataProvider textProvider
20
	 */
21
	public function testTokenize( $text, $expected ) {
22
23
		$this->assertEquals(
24
			$expected,
25
			Tokenizer::tokenize( $text )
26
		);
27
	}
28
29
	public function textProvider() {
30
31
		$provider[] = array(
0 ignored issues
show
Coding Style Comprehensibility introduced by
$provider was never initialized. Although not strictly required by PHP, it is generally a good practice to add $provider = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
32
			'foo',
33
			array( 'foo' )
34
		);
35
36
		$provider[] = array(
37
			'foo bar',
38
			array( 'foo', 'bar' )
39
		);
40
41
		return $provider;
42
	}
43
44
}
45