1 | <?php |
||
67 | class ContactObjectMutator extends AbstractObjectMutator |
||
68 | { |
||
69 | /** |
||
70 | * Use traits |
||
71 | */ |
||
72 | use NameMutatorTrait, AddressMutatorTrait; |
||
73 | |||
74 | /** |
||
75 | * Initialize the contact |
||
76 | * |
||
77 | * @param ObjectInterface $object Contact |
||
78 | * @return ObjectInterface Contact |
||
79 | */ |
||
80 | 1 | public function initialize(ObjectInterface $object) |
|
81 | { |
||
82 | 1 | $this->setRandomLocation($object, .6); // p-location |
|
83 | 1 | $this->setRandomDescription($object, .2); // p-summary |
|
84 | 1 | $this->setRandomCategories($object, .4); // p-category |
|
85 | 1 | $this->setRandomKeywords($object, .7); |
|
86 | 1 | $this->setAuthors($object); |
|
87 | |||
88 | // p-name - full/formatted name of the person or organisation (automatically set via the various name facets) |
||
89 | 1 | $this->setRandomHonorificPrefix($object, .3); // p-honorific-prefix - e.g. Mrs., Mr. or Dr. |
|
90 | 1 | $this->setGivenName($object); // p-given-name - given (often first) name |
|
91 | 1 | $this->setRandomNickname($object, .3); // p-nickname - nickname/alias/handle |
|
92 | 1 | $this->setRandomAdditionalName($object, .2); // p-additional-name - other/middle name |
|
93 | 1 | $this->setRandomFamilyName($object, .9);// p-family-name - family (often last) name |
|
94 | 1 | $this->setRandomHonorificSuffix($object, .1); // p-honorific-suffix - e.g. Ph.D, Esq. |
|
95 | 1 | $this->setSortString($object); // p-sort-string - string to sort by |
|
96 | |||
97 | 1 | $this->setRandomEmail($object, .5); // u-email - email address |
|
98 | 1 | $this->setRandomLogo($object, .2); // u-logo - a logo representing the person or organisation |
|
99 | 1 | $this->setRandomPhoto($object, .4); // u-photo |
|
100 | 1 | $this->setRandomUrl($object, .7); // u-url - home page |
|
101 | |||
102 | 1 | $this->happens(.4) ? |
|
103 | 1 | $this->setRandomAdr($object, .8) : // p-adr - postal address, optionally embed an h-adr |
|
104 | 1 | $this->initializeAddress($object); |
|
105 | 1 | $this->happens(.5) ? |
|
106 | 1 | $this->setRandomGeo($object, .8) : // u-geo |
|
107 | 1 | $this->initializeLatitudeLongitudeAltitude($object); |
|
108 | |||
109 | 1 | $this->setRandomTel($object, .5); |
|
110 | 1 | $this->setRandomNote($object, .3); |
|
111 | 1 | $this->setRandomBday($object, .3); |
|
112 | |||
113 | 1 | $this->setRandomKey($object, .2); |
|
114 | 1 | $this->setRandomOrg($object, .5); |
|
115 | 1 | $this->setRandomJobTitle($object, .4); |
|
116 | 1 | $this->setRandomRole($object, .4); |
|
117 | |||
118 | 1 | $this->setRandomImpp($object, .1); |
|
119 | 1 | $this->setRandomSex($object, .8); |
|
120 | 1 | $this->setRandomGenderIdentity($object, .8); |
|
121 | 1 | $this->setRandomAnniversary($object, .4); |
|
122 | |||
123 | 1 | return $object; |
|
124 | } |
||
125 | |||
126 | /** |
||
127 | * Initialize granular geo data |
||
128 | * |
||
129 | * @param ObjectInterface $object Object |
||
130 | */ |
||
131 | 1 | protected function initializeLatitudeLongitudeAltitude(ObjectInterface $object) |
|
139 | |||
140 | /** |
||
141 | * Mutate the article |
||
142 | * |
||
143 | * @param ObjectInterface $object Contact |
||
144 | * @return ObjectInterface Contact |
||
145 | */ |
||
146 | 1 | public function mutate(ObjectInterface $object) |
|
159 | |||
160 | /** |
||
161 | * Set the contact email |
||
162 | * |
||
163 | * @param ObjectInterface $object Contact |
||
164 | * @return ObjectInterface $object Contact |
||
165 | */ |
||
166 | 1 | protected function setEmail(ObjectInterface $object) |
|
171 | |||
172 | /** |
||
173 | * Set a logo |
||
174 | * |
||
175 | * @param ObjectInterface $object Contact |
||
176 | * @return ObjectInterface $object Contact |
||
177 | */ |
||
178 | 1 | protected function setLogo(ObjectInterface $object) |
|
179 | { |
||
180 | 1 | return $object->setDomainProperty(ContactProperties::LOGO, $this->generator->imageUrl()); |
|
181 | } |
||
182 | |||
183 | /** |
||
184 | * Set a photo |
||
185 | * |
||
186 | * @param ObjectInterface $object Contact |
||
187 | * @return ObjectInterface $object Contact |
||
188 | */ |
||
189 | 1 | protected function setPhoto(ObjectInterface $object) |
|
193 | |||
194 | /** |
||
195 | * Set a URL |
||
196 | * |
||
197 | * @param ObjectInterface $object Contact |
||
198 | * @return ObjectInterface $object Contact |
||
199 | */ |
||
200 | 1 | protected function setUrl(ObjectInterface $object) |
|
205 | |||
206 | /** |
||
207 | * Set a telephone number |
||
208 | * |
||
209 | * @param ObjectInterface $object Contact |
||
210 | * @return ObjectInterface $object Contact |
||
211 | */ |
||
212 | 1 | protected function setTel(ObjectInterface $object) |
|
213 | { |
||
214 | 1 | return $object->setDomainProperty(ContactProperties::TEL, '+'.$this->generator->randomNumber(8)); |
|
215 | } |
||
216 | |||
217 | /** |
||
218 | * Set an additional note |
||
219 | * |
||
220 | * @param ObjectInterface $object Contact |
||
221 | * @return ObjectInterface $object Contact |
||
222 | */ |
||
223 | 1 | protected function setNote(ObjectInterface $object) |
|
224 | { |
||
225 | 1 | return $object->setDomainProperty(ContactProperties::NOTE, $this->generator->text()); |
|
226 | } |
||
227 | |||
228 | /** |
||
229 | * Set a birthday |
||
230 | * |
||
231 | * @param ObjectInterface $object Contact |
||
232 | * @return ObjectInterface $object Contact |
||
233 | */ |
||
234 | 1 | protected function setBday(ObjectInterface $object) |
|
238 | |||
239 | /** |
||
240 | * Set a cryptographic key |
||
241 | * |
||
242 | * @param ObjectInterface $object Contact |
||
243 | * @return ObjectInterface $object Contact |
||
244 | */ |
||
245 | 1 | protected function setKey(ObjectInterface $object) |
|
246 | { |
||
247 | 1 | return $object->setDomainProperty( |
|
248 | 1 | ContactProperties::KEY, |
|
249 | 1 | '0x'.substr($this->generator->creditCardNumber, 0, 8) |
|
250 | ); |
||
251 | } |
||
252 | |||
253 | /** |
||
254 | * Set a birthday |
||
255 | * |
||
256 | * @param ObjectInterface $object Contact |
||
257 | * @return ObjectInterface $object Contact |
||
258 | */ |
||
259 | 1 | protected function setOrg(ObjectInterface $object) |
|
260 | { |
||
261 | 1 | if ($this->happens(.5)) { |
|
262 | 1 | return $object->setDomainProperty(ContactProperties::ORG, Random::apparatUrl(Object::CONTACT)); |
|
263 | } |
||
264 | |||
265 | 1 | return $object->setDomainProperty(ContactProperties::ORG, $this->generator->company); |
|
266 | } |
||
267 | |||
268 | /** |
||
269 | * Set a job title |
||
270 | * |
||
271 | * @param ObjectInterface $object Contact |
||
272 | * @return ObjectInterface $object Contact |
||
273 | */ |
||
274 | 1 | protected function setJobTitle(ObjectInterface $object) |
|
278 | |||
279 | /** |
||
280 | * Set a role |
||
281 | * |
||
282 | * @param ObjectInterface $object Contact |
||
283 | * @return ObjectInterface $object Contact |
||
284 | */ |
||
285 | 1 | protected function setRole(ObjectInterface $object) |
|
286 | { |
||
287 | 1 | return $object->setDomainProperty(ContactProperties::ROLE, $this->generator->jobTitle); |
|
288 | } |
||
289 | |||
290 | /** |
||
291 | * Set an instant messager profiel |
||
292 | * |
||
293 | * @param ObjectInterface $object Contact |
||
294 | * @return ObjectInterface $object Contact |
||
295 | */ |
||
296 | protected function setImpp(ObjectInterface $object) |
||
310 | |||
311 | /** |
||
312 | * Set a role |
||
313 | * |
||
314 | * @param ObjectInterface $object Contact |
||
315 | * @return ObjectInterface $object Contact |
||
316 | */ |
||
317 | 1 | protected function setSex(ObjectInterface $object) |
|
318 | { |
||
319 | 1 | return $object->setDomainProperty( |
|
320 | 1 | ContactProperties::SEX, |
|
321 | 1 | $this->generator->randomElement(['M', 'F', 'O', 'N', 'U']) |
|
322 | ); |
||
323 | } |
||
324 | |||
325 | /** |
||
326 | * Set a gender identity |
||
327 | * |
||
328 | * @param ObjectInterface $object Contact |
||
329 | * @return ObjectInterface $object Contact |
||
330 | */ |
||
331 | 1 | protected function setGenderIdentity(ObjectInterface $object) |
|
335 | |||
336 | /** |
||
337 | * Set a anniversary |
||
338 | * |
||
339 | * @param ObjectInterface $object Contact |
||
340 | * @return ObjectInterface $object Contact |
||
341 | */ |
||
342 | 1 | protected function setAnniversary(ObjectInterface $object) |
|
346 | } |
||
347 |