|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Feed; |
|
4
|
|
|
|
|
5
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Feed\Model\FeedAchievementValueObject; |
|
6
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Feed\Model\FeedBosskillValueObject; |
|
7
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Feed\Model\FeedLootValueObject; |
|
8
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\Model\AchievementValueObject; |
|
9
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\Shared\Criteria\Service\CriteriaService; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @author Willy Reiche |
|
13
|
|
|
* @since 2017-08-22 |
|
14
|
|
|
* @version 1.0 |
|
15
|
|
|
*/ |
|
16
|
|
|
class FeedObjectFactory |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @var CriteriaService |
|
20
|
|
|
*/ |
|
21
|
|
|
private $criteriaService; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* FeedObjectFactory constructor. |
|
25
|
|
|
*/ |
|
26
|
|
|
public function __construct() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->criteriaService = new CriteriaService(); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @param \StdClass $feed |
|
33
|
|
|
* @return FeedLootValueObject|FeedBosskillValueObject|FeedAchievementValueObject|null |
|
34
|
|
|
*/ |
|
35
|
|
|
public function getFeedObject($feed) |
|
36
|
|
|
{ |
|
37
|
|
|
$feedObj = null; |
|
38
|
|
|
|
|
39
|
|
|
switch ($feed->type) { |
|
40
|
|
|
case 'LOOT': |
|
41
|
|
|
$feedObj = new FeedLootValueObject( |
|
42
|
|
|
$feed->type, |
|
43
|
|
|
$feed->timestamp, |
|
44
|
|
|
$feed->itemId, |
|
45
|
|
|
$feed->context, |
|
46
|
|
|
$feed->bonusLists |
|
47
|
|
|
); |
|
48
|
|
|
break; |
|
49
|
|
|
case 'BOSSKILL': |
|
50
|
|
|
$achievement = $this->prepareAchievementValueObject($feed->achievement); |
|
51
|
|
|
|
|
52
|
|
|
$feedObj = new FeedBosskillValueObject( |
|
53
|
|
|
$feed->type, |
|
54
|
|
|
$feed->timestamp, |
|
55
|
|
|
$achievement, |
|
56
|
|
|
$feed->featOfStrength, |
|
57
|
|
|
$this->criteriaService->prepareCriteriaValueObject($feed->criteria), |
|
58
|
|
|
$feed->quantity, |
|
59
|
|
|
$feed->name |
|
60
|
|
|
); |
|
61
|
|
|
break; |
|
62
|
|
|
case 'ACHIEVEMENT': |
|
63
|
|
|
$achievement = $this->prepareAchievementValueObject($feed->achievement); |
|
64
|
|
|
|
|
65
|
|
|
$feedObj = new FeedAchievementValueObject( |
|
66
|
|
|
$feed->type, |
|
67
|
|
|
$feed->timestamp, |
|
68
|
|
|
$achievement, |
|
69
|
|
|
$feed->featOfStrength |
|
70
|
|
|
); |
|
71
|
|
|
break; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
return $feedObj; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @param \StdClass $achievement |
|
79
|
|
|
* @return AchievementValueObject |
|
80
|
|
|
*/ |
|
81
|
|
|
private function prepareAchievementValueObject($achievement) |
|
82
|
|
|
{ |
|
83
|
|
|
$criteria = []; |
|
84
|
|
|
|
|
85
|
|
|
foreach ($achievement->criteria as $singleCriteria) { |
|
86
|
|
|
$criteria[] = $this->criteriaService->prepareCriteriaValueObject($singleCriteria); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
return new AchievementValueObject( |
|
90
|
|
|
$achievement->id, |
|
91
|
|
|
$achievement->title, |
|
92
|
|
|
$achievement->points, |
|
93
|
|
|
$achievement->description, |
|
94
|
|
|
$achievement->rewardItems, |
|
95
|
|
|
$achievement->icon, |
|
96
|
|
|
$criteria, |
|
97
|
|
|
$achievement->accountWide, |
|
98
|
|
|
$achievement->factionId |
|
99
|
|
|
); |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|