Completed
Push — master ( a02710...7ee086 )
by Jelle
09:44
created

PropertyMap::getSource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
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 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * To change this license header, choose License Headers in Project Properties.
5
 * To change this template file, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
9
namespace TheSportsDb\PropertyMapper;
10
11
/**
12
 * Description of PropertyMap
13
 *
14
 * @author drupalpro
15
 */
16
class PropertyMap {
17
18
  protected $source;
19
20
  protected $destination;
21
22
  protected $transform;
23
24
  protected $reverse;
25
26
  public function __construct(PropertyDefinition $source, PropertyDefinition $destination, callable $transform = NULL, callable $reverse = NULL) {
27
    $this->source = $source;
28
    $this->destination = $destination;
29
    if (is_null($transform) !== is_null($reverse)) {
30
      throw new \InvalidArgumentException('Each transform function should have a reverse function and vice versa.');
31
    }
32
    $this->transform = $transform;
33
    $this->reverse = $reverse;
34
  }
35
36
  /**
37
   * Gets the source property.
38
   *
39
   * @return PropertyDefinition
40
   */
41
  public function getSource() {
42
    return $this->source;
43
  }
44
45
  /**
46
   * Gets the destination property.
47
   *
48
   * @return PropertyDefinition
49
   */
50
  public function getDestination() {
51
    return $this->destination;
52
  }
53
54
  public function getTransform() {
55
    return $this->transform;
56
  }
57
58
  public function getReverse() {
59
    return $this->reverse;
60
  }
61
62
}
63