FactoryTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 6
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testNewStopwatchFetcherReturnsFetcherThatUsesStopwatch() 0 12 1
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace FileFetcher\Stopwatch\Tests\Integration;
6
7
use FileFetcher\Stopwatch\Factory;
8
use FileFetcher\StubFileFetcher;
9
use PHPUnit\Framework\TestCase;
10
use Symfony\Component\Stopwatch\Stopwatch;
11
12
/**
13
 * @covers \FileFetcher\Stopwatch\Factory
14
 *
15
 * @licence BSD-3-Clause
16
 * @author Jeroen De Dauw < [email protected] >
17
 */
18
class FactoryTest extends TestCase {
19
20
	public function testNewStopwatchFetcherReturnsFetcherThatUsesStopwatch() {
21
		$stopwatch = $this->createMock( Stopwatch::class );
22
		$stopwatch->expects( $this->once() )->method( 'start' );
23
		$stopwatch->expects( $this->once() )->method( 'stop' );
24
25
		$fetcher = ( new Factory() )->newStopwatchFetcher(
26
			new StubFileFetcher( '' ),
27
			$stopwatch
0 ignored issues
show
Documentation introduced by
$stopwatch is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Symfony\Component\Stopwatch\Stopwatch>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
28
		);
29
30
		$fetcher->fetchFile( 'whatever' );
31
	}
32
33
}
34