|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* YAWIK Stackoverflow API |
|
4
|
|
|
* |
|
5
|
|
|
* @filesource |
|
6
|
|
|
* @license MIT |
|
7
|
|
|
* @copyright 2016- 2017 Cross Solution <http://cross-solution.de> |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
/** */ |
|
11
|
|
|
namespace StackoverflowApi\Entity; |
|
12
|
|
|
|
|
13
|
|
|
use Core\Entity\Collection\ArrayCollection; |
|
14
|
|
|
use Core\Entity\EntityTrait; |
|
15
|
|
|
use Core\Entity\IdentifiableEntityTrait; |
|
16
|
|
|
use Doctrine\Common\Collections\Collection; |
|
17
|
|
|
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Stackoverflow specific data container to be attached to a job entity. |
|
21
|
|
|
* |
|
22
|
|
|
* @ODM\Document(collection="stackoverflowapi.jobdata", repositoryClass="\Core\Repository\DefaultRepository") |
|
23
|
|
|
* |
|
24
|
|
|
* @author Mathias Gelhausen <[email protected]> |
|
25
|
|
|
* @since 0.1.0 |
|
26
|
|
|
*/ |
|
27
|
|
|
class JobData implements JobDataInterface |
|
28
|
|
|
{ |
|
29
|
|
|
use EntityTrait, IdentifiableEntityTrait; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* The id of the associated job |
|
33
|
|
|
* |
|
34
|
|
|
* @ODM\Field(type="string") |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
private $jobId; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* The external id (Stackoverflow API) |
|
41
|
|
|
* |
|
42
|
|
|
* @ODM\Field(type="int") |
|
43
|
|
|
* @var int |
|
44
|
|
|
*/ |
|
45
|
|
|
private $externalId; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* The external url. |
|
49
|
|
|
* |
|
50
|
|
|
* @ODM\Field(type="string") |
|
51
|
|
|
* @var string |
|
52
|
|
|
*/ |
|
53
|
|
|
private $externalUrl; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Flag wether the associated job is online. |
|
57
|
|
|
* |
|
58
|
|
|
* @ODM\Field(type="boolean") |
|
59
|
|
|
* @var bool |
|
60
|
|
|
*/ |
|
61
|
|
|
private $isOnline = false; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Api response stack. |
|
65
|
|
|
* |
|
66
|
|
|
* @ODM\EmbedMany(targetDocument="StackoverflowApi\Entity\ApiResponse") |
|
67
|
|
|
* @var Collection |
|
68
|
|
|
*/ |
|
69
|
|
|
private $responses; |
|
70
|
|
|
|
|
71
|
|
|
public function setJobId($id) |
|
72
|
|
|
{ |
|
73
|
|
|
$this->jobId = (string) $id; |
|
74
|
|
|
|
|
75
|
|
|
return $this; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function getJobId() |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->jobId; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function setExternalId($externalId) |
|
84
|
|
|
{ |
|
85
|
|
|
$this->externalId = $externalId; |
|
86
|
|
|
|
|
87
|
|
|
return $this; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public function getExternalId() |
|
91
|
|
|
{ |
|
92
|
|
|
return $this->externalId; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
public function setExternalUrl($externalUrl) |
|
96
|
|
|
{ |
|
97
|
|
|
$this->externalUrl = $externalUrl; |
|
98
|
|
|
|
|
99
|
|
|
return $this; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
public function getExternalUrl() |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->externalUrl; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
public function setIsOnline($flag) |
|
108
|
|
|
{ |
|
109
|
|
|
$this->isOnline = (bool) $flag; |
|
110
|
|
|
|
|
111
|
|
|
return $this; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
public function isOnline() |
|
115
|
|
|
{ |
|
116
|
|
|
return $this->isOnline; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public function addResponse(ApiResponseInterface $response) |
|
120
|
|
|
{ |
|
121
|
|
|
$this->getResponses()->add($response); |
|
122
|
|
|
|
|
123
|
|
|
return $this; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
public function getResponses() |
|
127
|
|
|
{ |
|
128
|
|
|
if (!$this->responses) { |
|
129
|
|
|
$this->responses = new ArrayCollection(); |
|
|
|
|
|
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
return $this->responses; |
|
|
|
|
|
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
public function getLastResponse() |
|
136
|
|
|
{ |
|
137
|
|
|
return $this->getResponses()->last(); |
|
138
|
|
|
} |
|
139
|
|
|
} |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..