GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Source::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Papper\Tests\MemberOptions\ConstructUsing;
4
5
use Papper\Engine;
6
use Papper\Tests\FixtureBase;
7
use Papper\Tests\TestCaseBase;
8
9
class ConstructUsingTest extends TestCaseBase
10
{
11
	public function testMappingUsingCustomConstructor()
12
	{
13
		// arrange
14
		$engine = new Engine();
15
		$engine->createMap(Source::className(), Destination::className())
16
			->constructUsing(function (Source $source){
17
				return new Destination($source->value);
18
			});
19
		// act
20
		/** @var Destination $destination */
21
		$destination = $engine->map(new Source('Some value'))->toType(Destination::className());
22
		// assert
23
		$this->assertEquals('Some value', $destination->getCtorValue());
24
	}
25
26
	public function testMappingShouldThrowExceptionWhenCreatedInvalidDestinationClass()
27
	{
28
		$this->setExpectedException('Papper\MappingException');
29
		// arrange
30
		$engine = new Engine();
31
		$engine->createMap(Source::className(), Destination::className())
32
			->constructUsing(function (Source $source){
33
				return new InvalidDestination($source->value);
0 ignored issues
show
Unused Code introduced by
The call to InvalidDestination::__construct() has too many arguments starting with $source->value.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
34
			});
35
		// act
36
		$engine->map(new Source('Some value'))->toType(Destination::className());
37
	}
38
}
39
40
class Source extends FixtureBase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
41
{
42
	public $value;
43
44
	public function __construct($value)
45
	{
46
		$this->value = $value;
47
	}
48
}
49
50
class Destination extends FixtureBase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
51
{
52
	private $ctorValue;
53
54
	public function __construct($ctorValue)
55
	{
56
		$this->ctorValue = $ctorValue;
57
	}
58
59
	public function getCtorValue()
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...
60
	{
61
		return $this->ctorValue;
62
	}
63
}
64
65
class InvalidDestination
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
66
{
67
}
68