Passed
Push — master ( 9a419b...81150f )
by Enrico
02:16
created

LocalBusiness::addAddressDescription()   B

Complexity

Conditions 9
Paths 20

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 9

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 13
cts 13
cp 1
rs 7.041
c 0
b 0
f 0
cc 9
eloc 13
nc 20
nop 0
crap 9
1
<?php
2
namespace BOTK\Model;
3
4
5
/**
6
 * An ibrid class that merge the semantic of schema:organization, schema:place and schema:geo, 
7
 * it is similar to schema:LocalBusiness.
8
 * Allows the bulk setup of properties
9
 */
10
class LocalBusiness extends AbstractModel implements \BOTK\ModelInterface 
11
{
12
13
	protected static $DEFAULT_OPTIONS = array (
14
		'businessType'		=> array(		
15
								// additional types  as extension of schema:LocalBusiness
16
			'filter'    => FILTER_DEFAULT,
17
			'flags'  	=> FILTER_FORCE_ARRAY
18
			),
19
		'taxID'				=> array(	
20
			'filter'    => FILTER_CALLBACK,
21
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_TOKEN',
22
			'flags'  	=> FILTER_REQUIRE_SCALAR
23
			),
24
		'vatID'				=> array(	// italian rules
25
			'filter'    => FILTER_VALIDATE_REGEXP,
26
			'options' 	=> array('regexp'=>'/^[0-9]{11}$/'),
27
			'flags'  	=> FILTER_REQUIRE_SCALAR
28
			),
29
		'legalName'			=> array(
30
			'filter'    => FILTER_CALLBACK,
31
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_ADDRESS',
32
			'flags'  	=> FILTER_REQUIRE_SCALAR
33
			),
34
		'businessName'		=> array(
35
								// a schema:alternateName for schema:PostalAddress
36
			'filter'    => FILTER_DEFAULT,
37
			'flags'  	=> FILTER_FORCE_ARRAY
38
			),
39
		'addressDescription'=> array(	//	
40
			'filter'    => FILTER_CALLBACK,
41
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_ADDRESS',
42
			'flags'  	=> FILTER_REQUIRE_SCALAR
43
			),
44
		'addressCountry'	=> array(
45
			'default'	=> 'IT',		
46
			'filter'    => FILTER_VALIDATE_REGEXP,
47
			'options' 	=> array('regexp'=>'/^[A-Z]{2}$/'),
48
			'flags'  	=> FILTER_REQUIRE_SCALAR
49
			),
50
		'addressLocality'	=> array(	
51
			'filter'    => FILTER_CALLBACK,
52
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_ADDRESS',
53
			'flags'  	=> FILTER_REQUIRE_SCALAR
54
			),
55
		'addressRegion'		=> array(	
56
			'filter'    => FILTER_CALLBACK,
57
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_ADDRESS',
58
			'flags'  	=> FILTER_REQUIRE_SCALAR
59
			),
60
		'streetAddress'		=> array(	
61
			'filter'    => FILTER_CALLBACK,
62
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_ADDRESS',
63
			'flags'  	=> FILTER_REQUIRE_SCALAR
64
			),
65
		'postalCode'		=> array(	// italian rules
66
			'filter'    => FILTER_VALIDATE_REGEXP,
67
			'options' 	=> array('regexp'=>'/^[0-9]{5}$/'),
68
			'flags'  	=> FILTER_REQUIRE_SCALAR
69
			),
70
		'telephone'			=> array(	
71
			'filter'    => FILTER_CALLBACK,	
72
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_TELEPHONE',
73
			'flags'  	=> FILTER_FORCE_ARRAY
74
			),
75
		'faxNumber'			=> array(	
76
			'filter'    => FILTER_CALLBACK,
77
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_TELEPHONE',
78
			'flags'  	=> FILTER_FORCE_ARRAY
79
			),
80
		'email'				=> array(	
81
			'filter'    => FILTER_CALLBACK,
82
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_EMAIL',
83
			'flags'  	=> FILTER_FORCE_ARRAY
84
			),
85
		'lat'				=> array( 
86
			'filter'    => FILTER_CALLBACK,
87
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_GEO'
88
			),
89
		'long'				=> array( 
90
			'filter'    => FILTER_CALLBACK,
91
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_GEO'
92
			),
93
		'similarStreet'		=> array(	
94
			'filter'    => FILTER_CALLBACK,
95
			'options' 	=> '\BOTK\Filters::FILTER_VALIDATE_URI',
96
			'flags'  	=> FILTER_FORCE_ARRAY
97
			),
98
		'hasMap'			=> array(	
99
			'filter'    => FILTER_CALLBACK,
100
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_HTTP_URL',
101
			'flags'  	=> FILTER_FORCE_ARRAY
102
			),
103
		'aggregateRatingValue'	=> array(	
104
			'filter'    => FILTER_VALIDATE_FLOAT,
105
			'flags'  	=> FILTER_REQUIRE_SCALAR
106
			),
107
		'openingHours'		   => array(	
108
			'filter'    => FILTER_DEFAULT,
109
			'flags'  	=> FILTER_REQUIRE_SCALAR
110
			),
111
		'near'				=> array(	
112
			'filter'    => FILTER_CALLBACK,
113
			'options' 	=> '\BOTK\Filters::FILTER_VALIDATE_URI',
114
			'flags'  	=> FILTER_FORCE_ARRAY
115
			),
116
		'similarName'		=> array(	
117
			'filter'    => FILTER_CALLBACK,
118
			'options' 	=> '\BOTK\Filters::FILTER_VALIDATE_URI',
119
			'flags'  	=> FILTER_FORCE_ARRAY
120
			),		
121
		'numberOfEmployees'	  => array(	
122
			'filter'    => FILTER_VALIDATE_REGEXP,
123
			'options' 	=> array('regexp'=>'/^[0-9]+\s*-?\s*[0-9]*$/'),
124
			'flags'  	=> FILTER_REQUIRE_SCALAR
125
			),
126
		'annualTurnover'	 => array(	
127
			'filter'    => FILTER_VALIDATE_REGEXP,
128
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
129
			'flags'  	=> FILTER_REQUIRE_SCALAR
130
			),
131
		'ateco2007'			=> array(	
132
			'filter'    => FILTER_VALIDATE_REGEXP,
133
			'options' 	=> array('regexp'=>'/^[0-9]{6}$/'),
134
			'flags'  	=> FILTER_REQUIRE_SCALAR
135
			),
136
		'ebitda'			=> array(	
137
			'filter'    => FILTER_VALIDATE_REGEXP,
138
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
139
			'flags'  	=> FILTER_REQUIRE_SCALAR
140
			),
141
		'netProfit'			=> array(	
142
			'filter'    => FILTER_VALIDATE_REGEXP,
143
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
144
			'flags'  	=> FILTER_REQUIRE_SCALAR
145
			),
146
		
147
		'naceV2'			=> array(	
148
			'filter'    => FILTER_VALIDATE_REGEXP,
149
			'options' 	=> array('regexp'=>'/^[0-9]{2}[.]?[0-9]{2}[.]?[0-9]{2}$/'),
150
			'flags'  	=> FILTER_REQUIRE_SCALAR
151
			),			
152
		/*==========================================6.3.0==========================================*/
153
		'isicV4'	=> array(	
154
			'filter'    => FILTER_VALIDATE_REGEXP,
155
			'options' 	=> array('regexp'=>'/^[0-9]{4}$/'),
156
			'flags'  	=> FILTER_REQUIRE_SCALAR
157
			),
158
		'hasTotDevelopers'	 => array(	
159
			'filter'    => FILTER_VALIDATE_REGEXP,
160
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
161
			'flags'  	=> FILTER_REQUIRE_SCALAR
162
			),
163
		'parentOrganization'	 => array(	
164
			'filter'    => FILTER_CALLBACK,
165
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_ID',
166
			'flags'  	=> FILTER_REQUIRE_SCALAR,
167
			),
168
		/*==========================================6.3.0 range==========================================*/
169
		'hasITEmployees'	 => array(	
170
			'filter'    => FILTER_VALIDATE_REGEXP,
171
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
172
			'flags'  	=> FILTER_REQUIRE_SCALAR
173
			),
174
		'hasNumberOfPCs'	 => array(	
175
			'filter'    => FILTER_VALIDATE_REGEXP,
176
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
177
			'flags'  	=> FILTER_REQUIRE_SCALAR
178
			),
179
		'hasITBudget'	 => array(	
180
			'filter'    => FILTER_VALIDATE_REGEXP,
181
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
182
			'flags'  	=> FILTER_REQUIRE_SCALAR
183
			),
184
		'hasTablets'	 => array(	
185
			'filter'    => FILTER_VALIDATE_REGEXP,
186
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
187
			'flags'  	=> FILTER_REQUIRE_SCALAR
188
			),
189
		'hasWorkstations'	 => array(	
190
			'filter'    => FILTER_VALIDATE_REGEXP,
191
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
192
			'flags'  	=> FILTER_REQUIRE_SCALAR
193
			),
194
		'hasStorageBudget'	 => array(	
195
			'filter'    => FILTER_VALIDATE_REGEXP,
196
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
197
			'flags'  	=> FILTER_REQUIRE_SCALAR
198
			),
199
		'hasServerBudget'	 => array(	
200
			'filter'    => FILTER_VALIDATE_REGEXP,
201
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
202
			'flags'  	=> FILTER_REQUIRE_SCALAR
203
			),
204
		'hasServers'	 => array(	
205
			'filter'    => FILTER_VALIDATE_REGEXP,
206
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
207
			'flags'  	=> FILTER_REQUIRE_SCALAR
208
			),
209
		'hasDesktop'	 => array(	
210
			'filter'    => FILTER_VALIDATE_REGEXP,
211
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
212
			'flags'  	=> FILTER_REQUIRE_SCALAR
213
			),
214
		'hasLaptops'	 => array(	
215
			'filter'    => FILTER_VALIDATE_REGEXP,
216
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
217
			'flags'  	=> FILTER_REQUIRE_SCALAR
218
			),
219
		'hasPrinters'	 => array(	
220
			'filter'    => FILTER_VALIDATE_REGEXP,
221
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
222
			'flags'  	=> FILTER_REQUIRE_SCALAR
223
			),
224
		'hasMultifunctionPrinters'	 => array(	
225
			'filter'    => FILTER_VALIDATE_REGEXP,
226
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
227
			'flags'  	=> FILTER_REQUIRE_SCALAR
228
			),
229
		'hasColorPrinter'	 => array(	
230
			'filter'    => FILTER_VALIDATE_REGEXP,
231
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
232
			'flags'  	=> FILTER_REQUIRE_SCALAR
233
			),
234
		'hasInternetUsers'	 => array(	
235
			'filter'    => FILTER_VALIDATE_REGEXP,
236
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
237
			'flags'  	=> FILTER_REQUIRE_SCALAR
238
			),
239
		'hasWirelessUsers'	 => array(	
240
			'filter'    => FILTER_VALIDATE_REGEXP,
241
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
242
			'flags'  	=> FILTER_REQUIRE_SCALAR
243
			),
244
		'hasNetworkLines'	 => array(	
245
			'filter'    => FILTER_VALIDATE_REGEXP,
246
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
247
			'flags'  	=> FILTER_REQUIRE_SCALAR
248
			),
249
		'hasRouters'	 => array(	
250
			'filter'    => FILTER_VALIDATE_REGEXP,
251
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
252
			'flags'  	=> FILTER_REQUIRE_SCALAR
253
			),
254
		'hasStorageCapacity'	 => array(	
255
			'filter'    => FILTER_VALIDATE_REGEXP,
256
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
257
			'flags'  	=> FILTER_REQUIRE_SCALAR
258
			),
259
		'hasExtensions'	 => array(	
260
			'filter'    => FILTER_VALIDATE_REGEXP,
261
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
262
			'flags'  	=> FILTER_REQUIRE_SCALAR
263
			),
264
		'hasTotCallCenterCallers'	 => array(	
265
			'filter'    => FILTER_VALIDATE_REGEXP,
266
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
267
			'flags'  	=> FILTER_REQUIRE_SCALAR
268
			),
269
		'hasThinPC'	 => array(	
270
			'filter'    => FILTER_VALIDATE_REGEXP,
271
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
272
			'flags'  	=> FILTER_REQUIRE_SCALAR
273
			),
274
		'hasSalesforce'	 => array(	
275
			'filter'    => FILTER_VALIDATE_REGEXP,
276
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
277
			'flags'  	=> FILTER_REQUIRE_SCALAR
278
			),
279
		'hasRevenue'	 => array(	
280
			'filter'    => FILTER_VALIDATE_REGEXP,
281
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
282
			'flags'  	=> FILTER_REQUIRE_SCALAR
283
			),
284
		'hasCommercialBudget'	 => array(	
285
			'filter'    => FILTER_VALIDATE_REGEXP,
286
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
287
			'flags'  	=> FILTER_REQUIRE_SCALAR
288
			),
289
		'hasHardwareBudget'	 => array(	
290
			'filter'    => FILTER_VALIDATE_REGEXP,
291
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
292
			'flags'  	=> FILTER_REQUIRE_SCALAR
293
			),
294
		'hasSoftwareBudget'	 => array(	
295
			'filter'    => FILTER_VALIDATE_REGEXP,
296
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
297
			'flags'  	=> FILTER_REQUIRE_SCALAR
298
			),
299
		'hasOutsrcingBudget'	 => array(	
300
			'filter'    => FILTER_VALIDATE_REGEXP,
301
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
302
			'flags'  	=> FILTER_REQUIRE_SCALAR
303
			),
304
		'hasOtherHardwareBudget'	 => array(	
305
			'filter'    => FILTER_VALIDATE_REGEXP,
306
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
307
			'flags'  	=> FILTER_REQUIRE_SCALAR
308
			),
309
		'hasPCBudget'	 => array(	
310
			'filter'    => FILTER_VALIDATE_REGEXP,
311
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
312
			'flags'  	=> FILTER_REQUIRE_SCALAR
313
			),
314
		'hasPrinterBudget'	 => array(	
315
			'filter'    => FILTER_VALIDATE_REGEXP,
316
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
317
			'flags'  	=> FILTER_REQUIRE_SCALAR
318
			),
319
		'hasTerminalBudget'	 => array(	
320
			'filter'    => FILTER_VALIDATE_REGEXP,
321
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
322
			'flags'  	=> FILTER_REQUIRE_SCALAR
323
			),
324
		'hasPeripheralBudget'	 => array(	
325
			'filter'    => FILTER_VALIDATE_REGEXP,
326
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
327
			'flags'  	=> FILTER_REQUIRE_SCALAR
328
			),
329
		'hasDesktopPrinters'	 => array(	
330
			'filter'    => FILTER_VALIDATE_REGEXP,
331
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
332
			'flags'  	=> FILTER_REQUIRE_SCALAR
333
			),
334
		'hasNetworkPrinters'	 => array(	
335
			'filter'    => FILTER_VALIDATE_REGEXP,
336
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
337
			'flags'  	=> FILTER_REQUIRE_SCALAR
338
			),
339
		'hasSmartphoneUsers'	 => array(	
340
			'filter'    => FILTER_VALIDATE_REGEXP,
341
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
342
			'flags'  	=> FILTER_REQUIRE_SCALAR
343
			),
344
		'hasEnterpriseSmartphoneUsers'	 => array(	
345
			'filter'    => FILTER_VALIDATE_REGEXP,
346
			'options' 	=> array('regexp'=>'/^-?[0-9]+\s*-?\s*-?[0-9]*$/'),
347
			'flags'  	=> FILTER_REQUIRE_SCALAR
348
			),
349
		/*=======================================6.3.0 string=======================================*/
350
		'hasServerManufacturer'	 => array(	
351
			'filter'    => FILTER_DEFAULT,
352
			'flags'  	=> FILTER_REQUIRE_SCALAR
353
			),
354
		'hasServerVirtualizationManufacturer'	 => array(	
355
			'filter'    => FILTER_DEFAULT,
356
			'flags'  	=> FILTER_REQUIRE_SCALAR
357
			),
358
		'hasDASManufacturer'	 => array(	
359
			'filter'    => FILTER_DEFAULT,
360
			'flags'  	=> FILTER_REQUIRE_SCALAR
361
			),
362
		'hasNASManufacturer'	 => array(	
363
			'filter'    => FILTER_DEFAULT,
364
			'flags'  	=> FILTER_REQUIRE_SCALAR
365
			),
366
		'hasSANManufacturer'	 => array(	
367
			'filter'    => FILTER_DEFAULT,
368
			'flags'  	=> FILTER_REQUIRE_SCALAR
369
			),
370
		'hasTapeLibraryManufacturer'	 => array(	
371
			'filter'    => FILTER_DEFAULT,
372
			'flags'  	=> FILTER_REQUIRE_SCALAR
373
			),
374
		'hasStorageVirtualizationManufacturer'	 => array(	
375
			'filter'    => FILTER_DEFAULT,
376
			'flags'  	=> FILTER_REQUIRE_SCALAR
377
			),
378
		'naics'	 => array(	
379
			'filter'    => FILTER_DEFAULT,
380
			'flags'  	=> FILTER_REQUIRE_SCALAR
381
			),
382
		'hasNAFCode'	 => array(	
383
			'filter'    => FILTER_DEFAULT,
384
			'flags'  	=> FILTER_REQUIRE_SCALAR
385
			),
386
		'hasServerSeries'	 => array(	
387
			'filter'    => FILTER_DEFAULT,
388
			'flags'  	=> FILTER_REQUIRE_SCALAR
389
			),
390
		'hasDesktopManufacturer'	 => array(	
391
			'filter'    => FILTER_DEFAULT,
392
			'flags'  	=> FILTER_REQUIRE_SCALAR
393
			),
394
		'hasLaptopManufacturer'	 => array(	
395
			'filter'    => FILTER_DEFAULT,
396
			'flags'  	=> FILTER_REQUIRE_SCALAR
397
			),
398
		'hasDesktopVirtualizationManufacturer'	 => array(	
399
			'filter'    => FILTER_DEFAULT,
400
			'flags'  	=> FILTER_REQUIRE_SCALAR
401
			),
402
		'hasWorkstationManufacturer'	 => array(	
403
			'filter'    => FILTER_DEFAULT,
404
			'flags'  	=> FILTER_REQUIRE_SCALAR
405
			),
406
		'hasNetworkPrinterManufacturer'	 => array(	
407
			'filter'    => FILTER_DEFAULT,
408
			'flags'  	=> FILTER_REQUIRE_SCALAR
409
			),
410
		'hasHighVolumePrinterManufacturer'	 => array(	
411
			'filter'    => FILTER_DEFAULT,
412
			'flags'  	=> FILTER_REQUIRE_SCALAR
413
			),
414
		'hasCopierManufacturer'	 => array(	
415
			'filter'    => FILTER_DEFAULT,
416
			'flags'  	=> FILTER_REQUIRE_SCALAR
417
			),
418
		'hasUPSManufacturer'	 => array(	
419
			'filter'    => FILTER_DEFAULT,
420
			'flags'  	=> FILTER_REQUIRE_SCALAR
421
			),
422
		'hasERPSuiteVendor'	 => array(	
423
			'filter'    => FILTER_DEFAULT,
424
			'flags'  	=> FILTER_REQUIRE_SCALAR
425
			),
426
		'hasERPSoftwareasaServiceManufacturer'	 => array(	
427
			'filter'    => FILTER_DEFAULT,
428
			'flags'  	=> FILTER_REQUIRE_SCALAR
429
			),
430
		'hasAppServerSoftwareVendor'	 => array(	
431
			'filter'    => FILTER_DEFAULT,
432
			'flags'  	=> FILTER_REQUIRE_SCALAR
433
			),
434
		'hasBusIntellSoftwareVendor'	 => array(	
435
			'filter'    => FILTER_DEFAULT,
436
			'flags'  	=> FILTER_REQUIRE_SCALAR
437
			),
438
		'hasCollaborativeSoftwareVendor'	 => array(	
439
			'filter'    => FILTER_DEFAULT,
440
			'flags'  	=> FILTER_REQUIRE_SCALAR
441
			),
442
		'hasCRMSoftwareVendor'	 => array(	
443
			'filter'    => FILTER_DEFAULT,
444
			'flags'  	=> FILTER_REQUIRE_SCALAR
445
			),
446
		'hasCRMSoftwareasaServiceManufacturer'	 => array(	
447
			'filter'    => FILTER_DEFAULT,
448
			'flags'  	=> FILTER_REQUIRE_SCALAR
449
			),
450
		'hasDocumentMgmtSoftwareVendor'	 => array(	
451
			'filter'    => FILTER_DEFAULT,
452
			'flags'  	=> FILTER_REQUIRE_SCALAR
453
			),
454
		'hasAppConsolidationSoftwareVendor'	 => array(	
455
			'filter'    => FILTER_DEFAULT,
456
			'flags'  	=> FILTER_REQUIRE_SCALAR
457
			),
458
		'hasHumanResourceSoftwareVendor'	 => array(	
459
			'filter'    => FILTER_DEFAULT,
460
			'flags'  	=> FILTER_REQUIRE_SCALAR
461
			),
462
		'hasSupplyChainSoftwareVendor'	 => array(	
463
			'filter'    => FILTER_DEFAULT,
464
			'flags'  	=> FILTER_REQUIRE_SCALAR
465
			),
466
		'hasWebServiceSoftwareVendor'	 => array(	
467
			'filter'    => FILTER_DEFAULT,
468
			'flags'  	=> FILTER_REQUIRE_SCALAR
469
			),
470
		'hasDatawarehouseSoftwareVendor'	 => array(	
471
			'filter'    => FILTER_DEFAULT,
472
			'flags'  	=> FILTER_REQUIRE_SCALAR
473
			),
474
		'hasSaaSVendor'	 => array(	
475
			'filter'    => FILTER_DEFAULT,
476
			'flags'  	=> FILTER_REQUIRE_SCALAR
477
			),
478
		'hasEmailMessagingVendor'	 => array(	
479
			'filter'    => FILTER_DEFAULT,
480
			'flags'  	=> FILTER_REQUIRE_SCALAR
481
			),
482
		'hasEmailSaaSManufacturer'	 => array(	
483
			'filter'    => FILTER_DEFAULT,
484
			'flags'  	=> FILTER_REQUIRE_SCALAR
485
			),
486
		'hasOSVendor'	 => array(	
487
			'filter'    => FILTER_DEFAULT,
488
			'flags'  	=> FILTER_REQUIRE_SCALAR
489
			),
490
		'hasOSModel'	 => array(	
491
			'filter'    => FILTER_DEFAULT,
492
			'flags'  	=> FILTER_REQUIRE_SCALAR
493
			),
494
		'hasDBMSVendor'	 => array(	
495
			'filter'    => FILTER_DEFAULT,
496
			'flags'  	=> FILTER_REQUIRE_SCALAR
497
			),
498
		'hasAcctingVendor'	 => array(	
499
			'filter'    => FILTER_DEFAULT,
500
			'flags'  	=> FILTER_REQUIRE_SCALAR
501
			),
502
		'hasAntiVirusVendor'	 => array(	
503
			'filter'    => FILTER_DEFAULT,
504
			'flags'  	=> FILTER_REQUIRE_SCALAR
505
			),
506
		'hasAssetManagementSoftwareVendor'	 => array(	
507
			'filter'    => FILTER_DEFAULT,
508
			'flags'  	=> FILTER_REQUIRE_SCALAR
509
			),
510
		'hasEnterpriseManagementSoftwareVendor'	 => array(	
511
			'filter'    => FILTER_DEFAULT,
512
			'flags'  	=> FILTER_REQUIRE_SCALAR
513
			),
514
		'hasIDAccessSoftwareVendor'	 => array(	
515
			'filter'    => FILTER_DEFAULT,
516
			'flags'  	=> FILTER_REQUIRE_SCALAR
517
			),
518
		'hasStorageManagementSoftwareVendor'	 => array(	
519
			'filter'    => FILTER_DEFAULT,
520
			'flags'  	=> FILTER_REQUIRE_SCALAR
521
			),
522
		'hasStorageSaaSManufacturer'	 => array(	
523
			'filter'    => FILTER_DEFAULT,
524
			'flags'  	=> FILTER_REQUIRE_SCALAR
525
			),
526
		'hasEthernetTechnology'	 => array(	
527
			'filter'    => FILTER_DEFAULT,
528
			'flags'  	=> FILTER_REQUIRE_SCALAR
529
			),
530
		'haseCommerceType'	 => array(	
531
			'filter'    => FILTER_DEFAULT,
532
			'flags'  	=> FILTER_REQUIRE_SCALAR
533
			),
534
		'hasHostorRemoteStatus'	 => array(	
535
			'filter'    => FILTER_DEFAULT,
536
			'flags'  	=> FILTER_REQUIRE_SCALAR
537
			),
538
		'hasNetworkLineCarrier'	 => array(	
539
			'filter'    => FILTER_DEFAULT,
540
			'flags'  	=> FILTER_REQUIRE_SCALAR
541
			),
542
		'hasVideoConfServicesProvider'	 => array(	
543
			'filter'    => FILTER_DEFAULT,
544
			'flags'  	=> FILTER_REQUIRE_SCALAR
545
			),
546
		'hasUnifiedCommSvcProvider'	 => array(	
547
			'filter'    => FILTER_DEFAULT,
548
			'flags'  	=> FILTER_REQUIRE_SCALAR
549
			),
550
		'hasRouterManufacturer'	 => array(	
551
			'filter'    => FILTER_DEFAULT,
552
			'flags'  	=> FILTER_REQUIRE_SCALAR
553
			),
554
		'hasSwitchManufacturer'	 => array(	
555
			'filter'    => FILTER_DEFAULT,
556
			'flags'  	=> FILTER_REQUIRE_SCALAR
557
			),
558
		'hasVPNManufacturer'	 => array(	
559
			'filter'    => FILTER_DEFAULT,
560
			'flags'  	=> FILTER_REQUIRE_SCALAR
561
			),
562
		'hasISP'	 => array(	
563
			'filter'    => FILTER_DEFAULT,
564
			'flags'  	=> FILTER_REQUIRE_SCALAR
565
			),
566
		'hasNetworkServiceProvider'	 => array(	
567
			'filter'    => FILTER_DEFAULT,
568
			'flags'  	=> FILTER_REQUIRE_SCALAR
569
			),
570
		'hasPhoneSystemManufacturer'	 => array(	
571
			'filter'    => FILTER_DEFAULT,
572
			'flags'  	=> FILTER_REQUIRE_SCALAR
573
			),
574
		'hasVoIPManufacturer'	 => array(	
575
			'filter'    => FILTER_DEFAULT,
576
			'flags'  	=> FILTER_REQUIRE_SCALAR
577
			),
578
		'hasVoIPHosting'	 => array(	
579
			'filter'    => FILTER_DEFAULT,
580
			'flags'  	=> FILTER_REQUIRE_SCALAR
581
			),
582
		'hasLongDistanceCarrier'	 => array(	
583
			'filter'    => FILTER_DEFAULT,
584
			'flags'  	=> FILTER_REQUIRE_SCALAR
585
			),
586
		'hasWirelessProvider'	 => array(	
587
			'filter'    => FILTER_DEFAULT,
588
			'flags'  	=> FILTER_REQUIRE_SCALAR
589
			),
590
		'hasPhoneSystemMaintenanceProvider'	 => array(	
591
			'filter'    => FILTER_DEFAULT,
592
			'flags'  	=> FILTER_REQUIRE_SCALAR
593
			),
594
		'hasSmartphoneManufacturer'	 => array(	
595
			'filter'    => FILTER_DEFAULT,
596
			'flags'  	=> FILTER_REQUIRE_SCALAR
597
			),
598
		'hasSmartphoneOS'	 => array(	
599
			'filter'    => FILTER_DEFAULT,
600
			'flags'  	=> FILTER_REQUIRE_SCALAR
601
			),
602
		'hasFYE'	 => array(	
603
			'filter'    => FILTER_VALIDATE_REGEXP,
604
			'options' 	=> array('regexp'=>'/^[A-Z]{3}$/'),
605
			'flags'  	=> FILTER_REQUIRE_SCALAR
606
			)
607
		);
608
609
	/**
610
	 * Redefine protected constructor to add address description as dynamic property
611
	 */
612 13
	protected function __construct(array $data = array(), array $customOptions = array()) 
613
	{
614 13
		parent::__construct($data, $customOptions);
615 13
		$this->addAddressDescription();
616 13
	}
617
	
618
	
619
	/**
620
	 * If not existing, create an address description as a normalized address from following data properties:
621
	 * 		'addressLocality',
622
	 * 		'addressRegion',
623
	 * 		'streetAddress',
624
	 * 		'postalCode',
625
	 */
626 13
	private function addAddressDescription()
627
	{	
628 13
		extract($this->data);
629
630 13
		if(empty($addressDescription)){
631 10
			if( !empty($streetAddress) && ( !empty($addressLocality) || !empty($postalCode))){
632 4
				$addressDescription = "$streetAddress ,";
633 4
				if(!empty($postalCode)) { $addressDescription.= " $postalCode";}
634 4
				if(!empty($addressLocality)) { $addressDescription.= " $addressLocality"; }
635 4
				if(!empty($addressRegion)) { $addressDescription.= " ($addressRegion)"; }
636
			} else {
637 6
				$addressDescription = null;
638
			}
639
		}
640
		
641 13
		$addressDescription = \BOTK\Filters::FILTER_SANITIZE_ADDRESS($addressDescription);
642
		
643 13
		if(!empty($addressDescription)){
644 7
			$this->data['addressDescription']=$addressDescription;
645
		}
646 13
	}
647
	
648
	
649 4
	public function asTurtleFragment()
650
	{
651 4
		if(is_null($this->rdf)) {
652 4
			extract($this->data);
653
654
			//die(print_r($this->data, true));
0 ignored issues
show
Unused Code Comprehensibility introduced by
77% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
655
656
			// create uris
657 4
			$organizationUri = $this->getUri();
658 4
			$addressUri = $organizationUri.'_address';
659 4
			$geoUri = ( !empty($lat) && !empty($long) )?"geo:$lat,$long":null;
660
			
661 4
			$tripleCounter =0;
662 4
			$turtleString='';
663
			
664
			// define $_ as a macro to write simple rdf
665 4
			$_= function($format, $var,$sanitize=true) use(&$turtleString, &$tripleCounter){
666 4
				foreach((array)$var as $v){
667 4
					if($var){
668 4
						$turtleString.= sprintf($format,$sanitize?\BOTK\Filters::FILTER_SANITIZE_TURTLE_STRING($v):$v);
669 4
						$tripleCounter++;
670
					}
671
				}
672 4
			};
673
674
	 		// serialize schema:LocalBusiness
675
			$_('<%s> a schema:LocalBusiness;', $organizationUri);
676
			!empty($businessType) 		&& $_('a %s;', $businessType);
677
			!empty($id) 				&& $_('dct:identifier "%s";', $id);
678
			!empty($vatID) 				&& $_('schema:vatID "%s";', $vatID); 
679
			!empty($taxtID) 			&& $_('schema:taxtID "%s";', $taxID);
680
			!empty($legalName)			&& $_('schema:legalName "%s";', $legalName);
681
			!empty($businessName) 		&& $_('schema:alternateName "%s";', $businessName);
682
			!empty($telephone) 			&& $_('schema:telephone "%s";', $telephone);
683
			!empty($faxNumber) 			&& $_('schema:faxNumber "%s";', $faxNumber);
684
			!empty($openingHours)		&& $_('schema:openingHours "%s";', $openingHours);
685
			!empty($disambiguatingDescription)&& $_('schema:disambiguatingDescription "%s";', $disambiguatingDescription);
686
687
			!empty($ateco2007)			&& $_('botk:ateco2007 "%s";', $ateco2007);
688
			!empty($naceV2)				&& $_('botk:naceV2 "%s";', $naceV2);
689
			!empty($isicV4)				&& $_('botk:isicV4 %s;', $isicV4);
690
			!empty($parentOrganization)	&& $_('schema:parentOrganization <%s>;', $base.$parentOrganization, false);
691
692
			!empty($aggregateRatingValue)&& $_('schema:aggregateRating [a schema:AggregateRating; schema:ratingValue "%s"^^xsd:float];', $aggregateRatingValue);
693
			!empty($page) 				&& $_('foaf:page <%s>;', $page,false);
694
			!empty($email) 				&& $_('schema:email "%s";', $email);
695
			!empty($homepage) 			&& $_('foaf:homepage <%s>;', $homepage,false);
696
			!empty($geoUri) 			&& $_('schema:geo <%s>;', $geoUri,false);
697
			!empty($hasMap) 			&& $_('schema:hasMap <%s>;', $hasMap,false);
698
			$_('schema:address <%s>. ', $addressUri);
699
			
700
			// serialize schema:PostalAddress 
701
			$_('<%s> a schema:PostalAddress;', $addressUri);
702
			!empty($addressDescription) && $_('schema:description "%s";', $addressDescription);
703
			!empty($streetAddress) 		&& $_('schema:streetAddress "%s";', $streetAddress);
704
			!empty($postalCode) 		&& $_('schema:postalCode "%s";', $postalCode);
705
			!empty($addressLocality) 	&& $_('schema:addressLocality "%s";', $addressLocality);
706
			!empty($addressRegion) 		&& $_('schema:addressRegion "%s";', $addressRegion);			
707
			$_('schema:addressCountry "%s". ', $addressCountry);
708
709
			// serialize schema:GeoCoordinates
710
			if( !empty($geoUri)){
711
				$_('<%s> a schema:GeoCoordinates;', $geoUri); 
712
				$_('wgs:lat "%s"^^xsd:float;', $lat);
713
				$_('wgs:long "%s"^^xsd:float . ', $long); 
714
			}
715
			
716
			$statVars = array(
717
				'numberOfEmployees',
718
				'annualTurnover',
719
				'ebitda',
720
				'netProfit',
721
				/*=======================================v6.3.0================================*/
722
				'hasTotDevelopers',
723
				'itBudget',
724
				'itStorageBudget',
725
				'itHardwareBudget',
726
				'itServerBudget',
727
				'softwareBudget',				
728
				'hasITEmployees',
729
				'hasNumberOfPCs',
730
				'hasITBudget',
731
				'hasTablets',
732
				'hasWorkstations',
733
				'hasStorageBudget',
734
				'hasServerBudget',
735
				'hasServers',
736
				'hasDesktop',
737
				'hasLaptops',
738
				'hasPrinters',
739
				'hasMultifunctionPrinters',
740
				'hasColorPrinter',
741
				'hasInternetUsers',
742
				'hasWirelessUsers',
743
				'hasNetworkLines',
744
				'hasRouters',
745
				'hasStorageCapacity',
746
				'hasExtensions',
747
				'hasTotCallCenterCallers',
748
				'hasThinPC',
749
				'hasSalesforce',
750
				'hasRevenue',
751
				'hasCommercialBudget',
752
				'hasHardwareBudget',
753
				'hasSoftwareBudget',
754
				'hasOutsrcingBudget',
755
				'hasOtherHardwareBudget',
756
				'hasPCBudget',
757
				'hasPrinterBudget',
758
				'hasTerminalBudget',
759
				'hasPeripheralBudget',
760
				'hasDesktopPrinters',
761
				'hasNetworkPrinters',
762
				'hasSmartphoneUsers',
763
				'hasEnterpriseSmartphoneUsers'				
764
				);
765
			
766
			/*
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
767
			accepted format : 123, 123-456, 0-123, 123-+, 123-inf, 123-PHP_INT_MAX
768
			*/
769
			foreach ( $statVars as $statVar){
770
				if(!empty($this->data[$statVar]) && preg_match('/^(-?[0-9]+)\s*-?\s*(inf|[+]|-?[0-9]*)$/', $this->data[$statVar], $matches)){
771
					$statUri =  $organizationUri.'_'.$statVar;
772
773
					$_("<$organizationUri> botk:$statVar <%s> .", $statUri, false);	
774
775
					$_('<%s> a schema:QuantitativeValue, botk:EstimatedRange;', $statUri);
776
					$minValue =  (int) $matches[1];
777
					$maxValue = empty($matches[2])? $minValue : $matches[2];
778
					if($maxValue == 'inf' || $maxValue == '+' || $maxValue == PHP_INT_MAX){
779
						$_('schema:minValue %s .', $minValue);
780
					}else{
781
						$_('schema:minValue %s ;', $minValue);
782
						$_('schema:maxValue %s .', $maxValue);
783
					}
784
				}		
785
			}
786
787
788
			$stringVars= array(
789
				/*=======================================v6.3.0================================*/
790
				'hasServerManufacturer',
791
				'hasServerVirtualizationManufacturer',
792
				'hasDASManufacturer',
793
				'hasNASManufacturer',
794
				'hasSANManufacturer',
795
				'hasTapeLibraryManufacturer',
796
				'hasStorageVirtualizationManufacturer',
797
				'naics',
798
				'hasNAFCode',
799
				'hasServerSeries',
800
				'hasDesktopManufacturer',
801
				'hasLaptopManufacturer',
802
				'hasDesktopVirtualizationManufacturer',
803
				'hasWorkstationManufacturer',
804
				'hasNetworkPrinterManufacturer',
805
				'hasHighVolumePrinterManufacturer',
806
				'hasCopierManufacturer',
807
				'hasUPSManufacturer',
808
				'hasERPSuiteVendor',
809
				'hasERPSoftwareasaServiceManufacturer',
810
				'hasAppServerSoftwareVendor',
811
				'hasBusIntellSoftwareVendor',
812
				'hasCollaborativeSoftwareVendor',
813
				'hasCRMSoftwareVendor',
814
				'hasCRMSoftwareasaServiceManufacturer',
815
				'hasDocumentMgmtSoftwareVendor',
816
				'hasAppConsolidationSoftwareVendor',
817
				'hasHumanResourceSoftwareVendor',
818
				'hasSupplyChainSoftwareVendor',
819
				'hasWebServiceSoftwareVendor',
820
				'hasDatawarehouseSoftwareVendor',
821
				'hasSaaSVendor',
822
				'hasEmailMessagingVendor',
823
				'hasEmailSaaSManufacturer',
824
				'hasOSVendor',
825
				'hasOSModel',
826
				'hasDBMSVendor',
827
				'hasAcctingVendor',
828
				'hasAntiVirusVendor',
829
				'hasAssetManagementSoftwareVendor',
830
				'hasEnterpriseManagementSoftwareVendor',
831
				'hasIDAccessSoftwareVendor',
832
				'hasStorageManagementSoftwareVendor',
833
				'hasStorageSaaSManufacturer',
834
				'hasEthernetTechnology',
835
				'haseCommerceType',
836
				'hasHostorRemoteStatus',
837
				'hasNetworkLineCarrier',
838
				'hasVideoConfServicesProvider',
839
				'hasUnifiedCommSvcProvider',
840
				'hasRouterManufacturer',
841
				'hasSwitchManufacturer',
842
				'hasVPNManufacturer',
843
				'hasISP',
844
				'hasNetworkServiceProvider',
845
				'hasPhoneSystemManufacturer',
846
				'hasVoIPManufacturer',
847
				'hasVoIPHosting',
848
				'hasLongDistanceCarrier',
849
				'hasWirelessProvider',
850
				'hasPhoneSystemMaintenanceProvider',
851
				'hasSmartphoneManufacturer',
852
				'hasSmartphoneOS',
853
				'hasFYE'
854
				);
855
856
			foreach ($stringVars as $stringVar) {
857
				if(!empty($this->data[$stringVar])){
858
					$_("<$organizationUri> botk:$stringVar \"%s\" .", $this->data[$stringVar]);	
859
				}
860
			}
861
862
			$this->rdf = $turtleString;
863
			$this->tripleCount = $tripleCounter;
864
		}
865
866
		return $this->rdf;
867
	}
868
869
}