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.

MappingContext::setSource()   B
last analyzed

Complexity

Conditions 7
Paths 4

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 14
rs 8.2222
cc 7
eloc 9
nc 4
nop 2
1
<?php
2
3
namespace Papper;
4
5
/**
6
 * Mapping context
7
 *
8
 * @author Vladimir Komissarov <[email protected]>
9
 */
10
class MappingContext
11
{
12
	private $source;
13
	private $sourceType;
14
	private $destination;
15
	private $destinationType;
16
17
	public function getSource()
18
	{
19
		return $this->source;
20
	}
21
22
	public function getSourceType()
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...
23
	{
24
		return $this->sourceType;
25
	}
26
27
	public function getDestination()
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...
28
	{
29
		return $this->destination;
30
	}
31
32
	public function getDestinationType()
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...
33
	{
34
		return $this->destinationType;
35
	}
36
37
	public function setSource($source, $sourceType)
38
	{
39
		if (!(is_object($source) || is_array($source))) {
40
			throw new MappingException('Source type must be object or array instead of ' . gettype($source));
41
		}
42
		if (is_array($source) && empty($sourceType)) {
43
			throw new MappingException('Source type must explicitly specified for collection mapping');
44
		}
45
		if (is_object($source) && empty($sourceType)) {
46
			$sourceType = get_class($source);
47
		}
48
		$this->source = $source;
49
		$this->sourceType = $sourceType;
50
	}
51
52
	public function setDestination($destination, $destinationType)
53
	{
54
		if ($destination !== null && is_array($this->source)) {
55
			throw new NotSupportedException('Collection mapping to existing destination is not supported');
56
		}
57
		if (is_object($destination) && empty($destinationType)) {
58
			$destinationType = get_class($destination);
59
		}
60
		if (empty($destinationType)) {
61
			throw new MappingException('Destination type must explicitly specified');
62
		}
63
		$this->destination = $destination;
64
		$this->destinationType = $destinationType;
65
	}
66
}
67