1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Stack Exchange Api Client library. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2015 Beñat Espiña <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace BenatEspina\StackExchangeApiClient\Model\Traits; |
13
|
|
|
|
14
|
|
|
use BenatEspina\StackExchangeApiClient\Model\Interfaces\MigrationInfoInterface; |
15
|
|
|
use BenatEspina\StackExchangeApiClient\Model\MigrationInfo; |
16
|
|
|
use BenatEspina\StackExchangeApiClient\Util\Util; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Trait MigrateTrait. |
20
|
|
|
* |
21
|
|
|
* @author Beñat Espiña <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
trait MigrateTrait |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* Migrated from. |
27
|
|
|
* |
28
|
|
|
* @var \BenatEspina\StackExchangeApiClient\Model\Interfaces\MigrationInfoInterface|null |
29
|
|
|
*/ |
30
|
|
|
protected $migratedFrom; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Migrated to. |
34
|
|
|
* |
35
|
|
|
* @var \BenatEspina\StackExchangeApiClient\Model\Interfaces\MigrationInfoInterface|null |
36
|
|
|
*/ |
37
|
|
|
protected $migratedTo; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Sets migrated from. |
41
|
|
|
* |
42
|
|
|
* @param \BenatEspina\StackExchangeApiClient\Model\Interfaces\MigrationInfoInterface|null $migratedFrom The |
|
|
|
|
43
|
|
|
* migration |
44
|
|
|
* info |
45
|
|
|
* |
46
|
|
|
* @return $this self Object |
47
|
|
|
*/ |
48
|
|
|
public function setMigratedFrom(MigrationInfoInterface $migratedFrom) |
49
|
|
|
{ |
50
|
|
|
$this->migratedFrom = $migratedFrom; |
51
|
|
|
|
52
|
|
|
return $this; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Gets migrated from. |
57
|
|
|
* |
58
|
|
|
* @return \BenatEspina\StackExchangeApiClient\Model\Interfaces\MigrationInfoInterface|null |
59
|
|
|
*/ |
60
|
|
|
public function getMigratedFrom() |
61
|
|
|
{ |
62
|
|
|
return $this->migratedFrom; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Sets migrated to. |
67
|
|
|
* |
68
|
|
|
* @param \BenatEspina\StackExchangeApiClient\Model\Interfaces\MigrationInfoInterface|null $migratedTo The |
|
|
|
|
69
|
|
|
* migration |
70
|
|
|
* info |
71
|
|
|
* |
72
|
|
|
* @return $this self Object |
73
|
|
|
*/ |
74
|
|
|
public function setMigratedTo(MigrationInfoInterface $migratedTo) |
75
|
|
|
{ |
76
|
|
|
$this->migratedTo = $migratedTo; |
77
|
|
|
|
78
|
|
|
return $this; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Gets migrated to. |
83
|
|
|
* |
84
|
|
|
* @return \BenatEspina\StackExchangeApiClient\Model\Interfaces\MigrationInfoInterface|null |
85
|
|
|
*/ |
86
|
|
|
public function getMigratedTo() |
87
|
|
|
{ |
88
|
|
|
return $this->migratedTo; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Loads the variables if the data exist into resource. It works like a constructor. |
93
|
|
|
* |
94
|
|
|
* @param null|mixed[] $resource The resource |
95
|
|
|
*/ |
96
|
|
|
protected function loadMigration($resource) |
97
|
|
|
{ |
98
|
|
|
$this->migratedFrom = new MigrationInfo(Util::setIfArrayExists($resource, 'migrated_from')); |
99
|
|
|
$this->migratedTo = new MigrationInfo(Util::setIfArrayExists($resource, 'migrated_to')); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|