Passed
Push — master ( b2d1c6...f85db0 )
by Enrico
01:53
created

LocalBusiness   A

Complexity

Total Complexity 31

Size/Duplication

Total Lines 855
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 31
lcom 1
cbo 2
dl 0
loc 855
ccs 31
cts 31
cp 1
rs 9.7142
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
B addAddressDescription() 0 21 9
F asTurtleFragment() 0 213 21
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
15
		'businessType'		=> array(		
16
								// additional types  as extension of schema:LocalBusiness
17
			'filter'    => FILTER_DEFAULT,
18
			'flags'  	=> FILTER_FORCE_ARRAY
19
			),
20
		'taxID'				=> array(	
21
			'filter'    => FILTER_CALLBACK,
22
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_TOKEN',
23
			'flags'  	=> FILTER_REQUIRE_SCALAR
24
			),
25
		'vatID'				=> array(	// italian rules
26
			'filter'    => FILTER_VALIDATE_REGEXP,
27
			'options' 	=> array('regexp'=>'/^[0-9]{11}$/'),
28
			'flags'  	=> FILTER_REQUIRE_SCALAR
29
			),
30
		'legalName'			=> array(
31
			'filter'    => FILTER_CALLBACK,
32
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_ADDRESS',
33
			'flags'  	=> FILTER_REQUIRE_SCALAR
34
			),
35
		'businessName'		=> array(
36
								// a schema:alternateName for schema:PostalAddress
37
			'filter'    => FILTER_DEFAULT,
38
			'flags'  	=> FILTER_FORCE_ARRAY
39
			),
40
		'addressDescription'=> array(	//	
41
			'filter'    => FILTER_CALLBACK,
42
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_ADDRESS',
43
			'flags'  	=> FILTER_REQUIRE_SCALAR
44
			),
45
		'addressCountry'	=> array(
46
			'default'	=> 'IT',		
47
			'filter'    => FILTER_VALIDATE_REGEXP,
48
			'options' 	=> array('regexp'=>'/^[A-Z]{2}$/'),
49
			'flags'  	=> FILTER_REQUIRE_SCALAR
50
			),
51
		'addressLocality'	=> array(	
52
			'filter'    => FILTER_CALLBACK,
53
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_ADDRESS',
54
			'flags'  	=> FILTER_REQUIRE_SCALAR
55
			),
56
		'addressRegion'		=> array(	
57
			'filter'    => FILTER_CALLBACK,
58
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_ADDRESS',
59
			'flags'  	=> FILTER_REQUIRE_SCALAR
60
			),
61
		'streetAddress'		=> array(	
62
			'filter'    => FILTER_CALLBACK,
63
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_ADDRESS',
64
			'flags'  	=> FILTER_REQUIRE_SCALAR
65
			),
66
		'postalCode'		=> array(	// italian rules
67
			'filter'    => FILTER_VALIDATE_REGEXP,
68
			'options' 	=> array('regexp'=>'/^[0-9]{5}$/'),
69
			'flags'  	=> FILTER_REQUIRE_SCALAR
70
			),
71
		'telephone'			=> array(	
72
			'filter'    => FILTER_CALLBACK,	
73
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_TELEPHONE',
74
			'flags'  	=> FILTER_FORCE_ARRAY
75
			),
76
		'faxNumber'			=> array(	
77
			'filter'    => FILTER_CALLBACK,
78
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_TELEPHONE',
79
			'flags'  	=> FILTER_FORCE_ARRAY
80
			),
81
		'email'				=> array(	
82
			'filter'    => FILTER_CALLBACK,
83
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_EMAIL',
84
			'flags'  	=> FILTER_FORCE_ARRAY
85
			),
86
		'lat'				=> array( 
87
			'filter'    => FILTER_CALLBACK,
88
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_GEO'
89
			),
90
		'long'				=> array( 
91
			'filter'    => FILTER_CALLBACK,
92
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_GEO'
93
			),
94
		'similarStreet'		=> array(	
95
			'filter'    => FILTER_CALLBACK,
96
			'options' 	=> '\BOTK\Filters::FILTER_VALIDATE_URI',
97
			'flags'  	=> FILTER_FORCE_ARRAY
98
			),
99
		'hasMap'			=> array(	
100
			'filter'    => FILTER_CALLBACK,
101
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_HTTP_URL',
102
			'flags'  	=> FILTER_FORCE_ARRAY
103
			),
104
		'aggregateRatingValue'	=> array(	
105
			'filter'    => FILTER_VALIDATE_FLOAT,
106
			'flags'  	=> FILTER_REQUIRE_SCALAR
107
			),
108
		'openingHours'		   => array(	
109
			'filter'    => FILTER_DEFAULT,
110
			'flags'  	=> FILTER_REQUIRE_SCALAR
111
			),
112
		'near'				=> array(	
113
			'filter'    => FILTER_CALLBACK,
114
			'options' 	=> '\BOTK\Filters::FILTER_VALIDATE_URI',
115
			'flags'  	=> FILTER_FORCE_ARRAY
116
			),
117
		'similarName'		=> array(	
118
			'filter'    => FILTER_CALLBACK,
119
			'options' 	=> '\BOTK\Filters::FILTER_VALIDATE_URI',
120
			'flags'  	=> FILTER_FORCE_ARRAY
121
			),		
122
		'numberOfEmployees'	  => array(	
123
			'filter'    => FILTER_VALIDATE_REGEXP,
124
			'options' 	=> array('regexp'=>'/^[0-9]+\s*-?\s*[0-9]*$/'),
125
			'flags'  	=> FILTER_REQUIRE_SCALAR
126
			),
127
		'annualTurnover'	 => array(	
128
			'filter'    => FILTER_CALLBACK,
129
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
130
			'flags'  	=> FILTER_REQUIRE_SCALAR
131
			),
132
		'ateco2007'			=> array(	
133
			'filter'    => FILTER_VALIDATE_REGEXP,
134
			'options' 	=> array('regexp'=>'/^[0-9]{6}$/'),
135
			'flags'  	=> FILTER_REQUIRE_SCALAR
136
			),
137
		'ebitda'			=> array(	
138
			'filter'    => FILTER_CALLBACK,
139
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
140
			'flags'  	=> FILTER_REQUIRE_SCALAR
141
			),
142
		'netProfit'			=> array(	
143
			'filter'    => FILTER_CALLBACK,
144
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
145
			'flags'  	=> FILTER_REQUIRE_SCALAR
146
			),
147
		
148
		'naceV2'			=> array(	
149
			'filter'    => FILTER_VALIDATE_REGEXP,
150
			'options' 	=> array('regexp'=>'/^[0-9]{2}[.]?[0-9]{1,2}$/'),
151
			'flags'  	=> FILTER_REQUIRE_SCALAR
152
			),			
153
		/*==========================================6.3.0==========================================*/
154
		'isicV4'	=> array(	
155
			'filter'    => FILTER_VALIDATE_REGEXP,
156
			'options' 	=> array('regexp'=>'/^[0-9]{4}$/'),
157
			'flags'  	=> FILTER_REQUIRE_SCALAR
158
			),
159
		'hasTotDevelopers'	 => array(	
160
			'filter'    => FILTER_CALLBACK,
161
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
162
			'flags'  	=> FILTER_REQUIRE_SCALAR
163
			),
164
		'parentOrganization'	 => array(	
165
			'filter'    => FILTER_CALLBACK,
166
			'options' 	=> '\BOTK\Filters::FILTER_VALIDATE_URI',
167
			'flags'  	=> FILTER_REQUIRE_SCALAR,
168
			),
169
		/*==========================================6.3.0 range==========================================*/
170
		'hasITEmployees'	 => array(	
171
			'filter'    => FILTER_CALLBACK,
172
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
173
			'flags'  	=> FILTER_REQUIRE_SCALAR
174
			),
175
		'hasNumberOfPCs'	 => array(	
176
			'filter'    => FILTER_CALLBACK,
177
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
178
			'flags'  	=> FILTER_REQUIRE_SCALAR
179
			),
180
		'hasITBudget'	 => array(	
181
			'filter'    => FILTER_CALLBACK,
182
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
183
			'flags'  	=> FILTER_REQUIRE_SCALAR
184
			),
185
		'hasTablets'	 => array(	
186
			'filter'    => FILTER_CALLBACK,
187
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
188
			'flags'  	=> FILTER_REQUIRE_SCALAR
189
			),
190
		'hasWorkstations'	 => array(	
191
			'filter'    => FILTER_CALLBACK,
192
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
193
			'flags'  	=> FILTER_REQUIRE_SCALAR
194
			),
195
		'hasStorageBudget'	 => array(	
196
			'filter'    => FILTER_CALLBACK,
197
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
198
			'flags'  	=> FILTER_REQUIRE_SCALAR
199
			),
200
		'hasServerBudget'	 => array(	
201
			'filter'    => FILTER_CALLBACK,
202
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
203
			'flags'  	=> FILTER_REQUIRE_SCALAR
204
			),
205
		'hasServers'	 => array(	
206
			'filter'    => FILTER_CALLBACK,
207
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
208
			'flags'  	=> FILTER_REQUIRE_SCALAR
209
			),
210
		'hasDesktop'	 => array(	
211
			'filter'    => FILTER_CALLBACK,
212
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
213
			'flags'  	=> FILTER_REQUIRE_SCALAR
214
			),
215
		'hasLaptops'	 => array(	
216
			'filter'    => FILTER_CALLBACK,
217
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
218
			'flags'  	=> FILTER_REQUIRE_SCALAR
219
			),
220
		'hasPrinters'	 => array(	
221
			'filter'    => FILTER_CALLBACK,
222
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
223
			'flags'  	=> FILTER_REQUIRE_SCALAR
224
			),
225
		'hasMultifunctionPrinters'	 => array(	
226
			'filter'    => FILTER_CALLBACK,
227
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
228
			'flags'  	=> FILTER_REQUIRE_SCALAR
229
			),
230
		'hasColorPrinter'	 => array(	
231
			'filter'    => FILTER_CALLBACK,
232
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
233
			'flags'  	=> FILTER_REQUIRE_SCALAR
234
			),
235
		'hasInternetUsers'	 => array(	
236
			'filter'    => FILTER_CALLBACK,
237
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
238
			'flags'  	=> FILTER_REQUIRE_SCALAR
239
			),
240
		'hasWirelessUsers'	 => array(	
241
			'filter'    => FILTER_CALLBACK,
242
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
243
			'flags'  	=> FILTER_REQUIRE_SCALAR
244
			),
245
		'hasNetworkLines'	 => array(	
246
			'filter'    => FILTER_CALLBACK,
247
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
248
			'flags'  	=> FILTER_REQUIRE_SCALAR
249
			),
250
		'hasRouters'	 => array(	
251
			'filter'    => FILTER_CALLBACK,
252
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
253
			'flags'  	=> FILTER_REQUIRE_SCALAR
254
			),
255
		'hasStorageCapacity'	 => array(	
256
			'filter'    => FILTER_CALLBACK,
257
			'options' 	=> '\BOTK\Filters::SANITIZE_STORAGE_CAPACITY',
258
			'flags'  	=> FILTER_REQUIRE_SCALAR
259
			),
260
		'hasExtensions'	 => array(	
261
			'filter'    => FILTER_CALLBACK,
262
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
263
			'flags'  	=> FILTER_REQUIRE_SCALAR
264
			),
265
		'hasTotCallCenterCallers'	 => array(	
266
			'filter'    => FILTER_CALLBACK,
267
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
268
			'flags'  	=> FILTER_REQUIRE_SCALAR
269
			),
270
		'hasThinPC'	 => array(	
271
			'filter'    => FILTER_CALLBACK,
272
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
273
			'flags'  	=> FILTER_REQUIRE_SCALAR
274
			),
275
		'hasSalesforce'	 => array(	
276
			'filter'    => FILTER_CALLBACK,
277
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
278
			'flags'  	=> FILTER_REQUIRE_SCALAR
279
			),
280
		'hasRevenue'	 => array(	
281
			'filter'    => FILTER_CALLBACK,
282
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
283
			'flags'  	=> FILTER_REQUIRE_SCALAR
284
			),
285
		'hasCommercialBudget'	 => array(	
286
			'filter'    => FILTER_CALLBACK,
287
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
288
			'flags'  	=> FILTER_REQUIRE_SCALAR
289
			),
290
		'hasHardwareBudget'	 => array(	
291
			'filter'    => FILTER_CALLBACK,
292
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
293
			'flags'  	=> FILTER_REQUIRE_SCALAR
294
			),
295
		'hasSoftwareBudget'	 => array(	
296
			'filter'    => FILTER_CALLBACK,
297
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
298
			'flags'  	=> FILTER_REQUIRE_SCALAR
299
			),
300
		'hasOutsrcingBudget'	 => array(	
301
			'filter'    => FILTER_CALLBACK,
302
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
303
			'flags'  	=> FILTER_REQUIRE_SCALAR
304
			),
305
		'hasOtherHardwareBudget'	 => array(	
306
			'filter'    => FILTER_CALLBACK,
307
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
308
			'flags'  	=> FILTER_REQUIRE_SCALAR
309
			),
310
		'hasPCBudget'	 => array(	
311
			'filter'    => FILTER_CALLBACK,
312
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
313
			'flags'  	=> FILTER_REQUIRE_SCALAR
314
			),
315
		'hasPrinterBudget'	 => array(	
316
			'filter'    => FILTER_CALLBACK,
317
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
318
			'flags'  	=> FILTER_REQUIRE_SCALAR
319
			),
320
		'hasTerminalBudget'	 => array(	
321
			'filter'    => FILTER_CALLBACK,
322
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
323
			'flags'  	=> FILTER_REQUIRE_SCALAR
324
			),
325
		'hasPeripheralBudget'	 => array(	
326
			'filter'    => FILTER_CALLBACK,
327
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
328
			'flags'  	=> FILTER_REQUIRE_SCALAR
329
			),
330
		'hasDesktopPrinters'	 => array(	
331
			'filter'    => FILTER_CALLBACK,
332
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
333
			'flags'  	=> FILTER_REQUIRE_SCALAR
334
			),
335
		'hasNetworkPrinters'	 => array(	
336
			'filter'    => FILTER_CALLBACK,
337
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
338
			'flags'  	=> FILTER_REQUIRE_SCALAR
339
			),
340
		'hasSmartphoneUsers'	 => array(	
341
			'filter'    => FILTER_CALLBACK,
342
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
343
			'flags'  	=> FILTER_REQUIRE_SCALAR
344
			),
345
		'hasEnterpriseSmartphoneUsers'	 => array(	
346
			'filter'    => FILTER_CALLBACK,
347
			'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_RANGE',
348
			'flags'  	=> FILTER_REQUIRE_SCALAR
349
			),
350
		/*=======================================6.3.0 string=======================================*/
351
		'hasServerManufacturer'	 => array(	
352
			'filter'    => FILTER_DEFAULT,
353
			'flags'  	=> FILTER_REQUIRE_SCALAR
354
			),
355
		'hasServerVirtualizationManufacturer'	 => array(	
356
			'filter'    => FILTER_DEFAULT,
357
			'flags'  	=> FILTER_REQUIRE_SCALAR
358
			),
359
		'hasDASManufacturer'	 => array(	
360
			'filter'    => FILTER_DEFAULT,
361
			'flags'  	=> FILTER_REQUIRE_SCALAR
362
			),
363
		'hasNASManufacturer'	 => array(	
364
			'filter'    => FILTER_DEFAULT,
365
			'flags'  	=> FILTER_REQUIRE_SCALAR
366
			),
367
		'hasSANManufacturer'	 => array(	
368
			'filter'    => FILTER_DEFAULT,
369
			'flags'  	=> FILTER_REQUIRE_SCALAR
370
			),
371
		'hasTapeLibraryManufacturer'	 => array(	
372
			'filter'    => FILTER_DEFAULT,
373
			'flags'  	=> FILTER_REQUIRE_SCALAR
374
			),
375
		'hasStorageVirtualizationManufacturer'	 => array(	
376
			'filter'    => FILTER_DEFAULT,
377
			'flags'  	=> FILTER_REQUIRE_SCALAR
378
			),
379
		'naics'	 => array(	
380
			'filter'    => FILTER_DEFAULT,
381
			'flags'  	=> FILTER_REQUIRE_SCALAR
382
			),
383
		'hasNAFCode'	 => array(	
384
			'filter'    => FILTER_DEFAULT,
385
			'flags'  	=> FILTER_REQUIRE_SCALAR
386
			),
387
		'hasServerSeries'	 => array(	
388
			'filter'    => FILTER_DEFAULT,
389
			'flags'  	=> FILTER_REQUIRE_SCALAR
390
			),
391
		'hasDesktopManufacturer'	 => array(	
392
			'filter'    => FILTER_DEFAULT,
393
			'flags'  	=> FILTER_REQUIRE_SCALAR
394
			),
395
		'hasLaptopManufacturer'	 => array(	
396
			'filter'    => FILTER_DEFAULT,
397
			'flags'  	=> FILTER_REQUIRE_SCALAR
398
			),
399
		'hasDesktopVirtualizationManufacturer'	 => array(	
400
			'filter'    => FILTER_DEFAULT,
401
			'flags'  	=> FILTER_REQUIRE_SCALAR
402
			),
403
		'hasWorkstationManufacturer'	 => array(	
404
			'filter'    => FILTER_DEFAULT,
405
			'flags'  	=> FILTER_REQUIRE_SCALAR
406
			),
407
		'hasNetworkPrinterManufacturer'	 => array(	
408
			'filter'    => FILTER_DEFAULT,
409
			'flags'  	=> FILTER_REQUIRE_SCALAR
410
			),
411
		'hasHighVolumePrinterManufacturer'	 => array(	
412
			'filter'    => FILTER_DEFAULT,
413
			'flags'  	=> FILTER_REQUIRE_SCALAR
414
			),
415
		'hasCopierManufacturer'	 => array(	
416
			'filter'    => FILTER_DEFAULT,
417
			'flags'  	=> FILTER_REQUIRE_SCALAR
418
			),
419
		'hasUPSManufacturer'	 => array(	
420
			'filter'    => FILTER_DEFAULT,
421
			'flags'  	=> FILTER_REQUIRE_SCALAR
422
			),
423
		'hasERPSuiteVendor'	 => array(	
424
			'filter'    => FILTER_DEFAULT,
425
			'flags'  	=> FILTER_REQUIRE_SCALAR
426
			),
427
		'hasERPSoftwareasaServiceManufacturer'	 => array(	
428
			'filter'    => FILTER_DEFAULT,
429
			'flags'  	=> FILTER_REQUIRE_SCALAR
430
			),
431
		'hasAppServerSoftwareVendor'	 => array(	
432
			'filter'    => FILTER_DEFAULT,
433
			'flags'  	=> FILTER_REQUIRE_SCALAR
434
			),
435
		'hasBusIntellSoftwareVendor'	 => array(	
436
			'filter'    => FILTER_DEFAULT,
437
			'flags'  	=> FILTER_REQUIRE_SCALAR
438
			),
439
		'hasCollaborativeSoftwareVendor'	 => array(	
440
			'filter'    => FILTER_DEFAULT,
441
			'flags'  	=> FILTER_REQUIRE_SCALAR
442
			),
443
		'hasCRMSoftwareVendor'	 => array(	
444
			'filter'    => FILTER_DEFAULT,
445
			'flags'  	=> FILTER_REQUIRE_SCALAR
446
			),
447
		'hasCRMSoftwareasaServiceManufacturer'	 => array(	
448
			'filter'    => FILTER_DEFAULT,
449
			'flags'  	=> FILTER_REQUIRE_SCALAR
450
			),
451
		'hasDocumentMgmtSoftwareVendor'	 => array(	
452
			'filter'    => FILTER_DEFAULT,
453
			'flags'  	=> FILTER_REQUIRE_SCALAR
454
			),
455
		'hasAppConsolidationSoftwareVendor'	 => array(	
456
			'filter'    => FILTER_DEFAULT,
457
			'flags'  	=> FILTER_REQUIRE_SCALAR
458
			),
459
		'hasHumanResourceSoftwareVendor'	 => array(	
460
			'filter'    => FILTER_DEFAULT,
461
			'flags'  	=> FILTER_REQUIRE_SCALAR
462
			),
463
		'hasSupplyChainSoftwareVendor'	 => array(	
464
			'filter'    => FILTER_DEFAULT,
465
			'flags'  	=> FILTER_REQUIRE_SCALAR
466
			),
467
		'hasWebServiceSoftwareVendor'	 => array(	
468
			'filter'    => FILTER_DEFAULT,
469
			'flags'  	=> FILTER_REQUIRE_SCALAR
470
			),
471
		'hasDatawarehouseSoftwareVendor'	 => array(	
472
			'filter'    => FILTER_DEFAULT,
473
			'flags'  	=> FILTER_REQUIRE_SCALAR
474
			),
475
		'hasSaaSVendor'	 => array(	
476
			'filter'    => FILTER_DEFAULT,
477
			'flags'  	=> FILTER_REQUIRE_SCALAR
478
			),
479
		'hasEmailMessagingVendor'	 => array(	
480
			'filter'    => FILTER_DEFAULT,
481
			'flags'  	=> FILTER_REQUIRE_SCALAR
482
			),
483
		'hasEmailSaaSManufacturer'	 => array(	
484
			'filter'    => FILTER_DEFAULT,
485
			'flags'  	=> FILTER_REQUIRE_SCALAR
486
			),
487
		'hasOSVendor'	 => array(	
488
			'filter'    => FILTER_DEFAULT,
489
			'flags'  	=> FILTER_REQUIRE_SCALAR
490
			),
491
		'hasOSModel'	 => array(	
492
			'filter'    => FILTER_DEFAULT,
493
			'flags'  	=> FILTER_REQUIRE_SCALAR
494
			),
495
		'hasDBMSVendor'	 => array(	
496
			'filter'    => FILTER_DEFAULT,
497
			'flags'  	=> FILTER_REQUIRE_SCALAR
498
			),
499
		'hasAcctingVendor'	 => array(	
500
			'filter'    => FILTER_DEFAULT,
501
			'flags'  	=> FILTER_REQUIRE_SCALAR
502
			),
503
		'hasAntiVirusVendor'	 => array(	
504
			'filter'    => FILTER_DEFAULT,
505
			'flags'  	=> FILTER_REQUIRE_SCALAR
506
			),
507
		'hasAssetManagementSoftwareVendor'	 => array(	
508
			'filter'    => FILTER_DEFAULT,
509
			'flags'  	=> FILTER_REQUIRE_SCALAR
510
			),
511
		'hasEnterpriseManagementSoftwareVendor'	 => array(	
512
			'filter'    => FILTER_DEFAULT,
513
			'flags'  	=> FILTER_REQUIRE_SCALAR
514
			),
515
		'hasIDAccessSoftwareVendor'	 => array(	
516
			'filter'    => FILTER_DEFAULT,
517
			'flags'  	=> FILTER_REQUIRE_SCALAR
518
			),
519
		'hasStorageManagementSoftwareVendor'	 => array(	
520
			'filter'    => FILTER_DEFAULT,
521
			'flags'  	=> FILTER_REQUIRE_SCALAR
522
			),
523
		'hasStorageSaaSManufacturer'	 => array(	
524
			'filter'    => FILTER_DEFAULT,
525
			'flags'  	=> FILTER_REQUIRE_SCALAR
526
			),
527
		'hasEthernetTechnology'	 => array(	
528
			'filter'    => FILTER_DEFAULT,
529
			'flags'  	=> FILTER_REQUIRE_SCALAR
530
			),
531
		'haseCommerceType'	 => array(	
532
			'filter'    => FILTER_DEFAULT,
533
			'flags'  	=> FILTER_REQUIRE_SCALAR
534
			),
535
		'hasHostorRemoteStatus'	 => array(	
536
			'filter'    => FILTER_DEFAULT,
537
			'flags'  	=> FILTER_REQUIRE_SCALAR
538
			),
539
		'hasNetworkLineCarrier'	 => array(	
540
			'filter'    => FILTER_DEFAULT,
541
			'flags'  	=> FILTER_REQUIRE_SCALAR
542
			),
543
		'hasVideoConfServicesProvider'	 => array(	
544
			'filter'    => FILTER_DEFAULT,
545
			'flags'  	=> FILTER_REQUIRE_SCALAR
546
			),
547
		'hasUnifiedCommSvcProvider'	 => array(	
548
			'filter'    => FILTER_DEFAULT,
549
			'flags'  	=> FILTER_REQUIRE_SCALAR
550
			),
551
		'hasRouterManufacturer'	 => array(	
552
			'filter'    => FILTER_DEFAULT,
553
			'flags'  	=> FILTER_REQUIRE_SCALAR
554
			),
555
		'hasSwitchManufacturer'	 => array(	
556
			'filter'    => FILTER_DEFAULT,
557
			'flags'  	=> FILTER_REQUIRE_SCALAR
558
			),
559
		'hasVPNManufacturer'	 => array(	
560
			'filter'    => FILTER_DEFAULT,
561
			'flags'  	=> FILTER_REQUIRE_SCALAR
562
			),
563
		'hasISP'	 => array(	
564
			'filter'    => FILTER_DEFAULT,
565
			'flags'  	=> FILTER_REQUIRE_SCALAR
566
			),
567
		'hasNetworkServiceProvider'	 => array(	
568
			'filter'    => FILTER_DEFAULT,
569
			'flags'  	=> FILTER_REQUIRE_SCALAR
570
			),
571
		'hasPhoneSystemManufacturer'	 => array(	
572
			'filter'    => FILTER_DEFAULT,
573
			'flags'  	=> FILTER_REQUIRE_SCALAR
574
			),
575
		'hasVoIPManufacturer'	 => array(	
576
			'filter'    => FILTER_DEFAULT,
577
			'flags'  	=> FILTER_REQUIRE_SCALAR
578
			),
579
		'hasVoIPHosting'	 => array(	
580
			'filter'    => FILTER_DEFAULT,
581
			'flags'  	=> FILTER_REQUIRE_SCALAR
582
			),
583
		'hasLongDistanceCarrier'	 => array(	
584
			'filter'    => FILTER_DEFAULT,
585
			'flags'  	=> FILTER_REQUIRE_SCALAR
586
			),
587
		'hasWirelessProvider'	 => array(	
588
			'filter'    => FILTER_DEFAULT,
589
			'flags'  	=> FILTER_REQUIRE_SCALAR
590
			),
591
		'hasPhoneSystemMaintenanceProvider'	 => array(	
592
			'filter'    => FILTER_DEFAULT,
593
			'flags'  	=> FILTER_REQUIRE_SCALAR
594
			),
595
		'hasSmartphoneManufacturer'	 => array(	
596
			'filter'    => FILTER_DEFAULT,
597
			'flags'  	=> FILTER_REQUIRE_SCALAR
598
			),
599
		'hasSmartphoneOS'	 => array(	
600
			'filter'    => FILTER_DEFAULT,
601
			'flags'  	=> FILTER_REQUIRE_SCALAR
602
			),
603
		'hasFYE'	 => array(	
604
			'filter'    => FILTER_VALIDATE_REGEXP,
605
			'options' 	=> array('regexp'=>'/^[A-Z]{3}$/'),
606
			'flags'  	=> FILTER_REQUIRE_SCALAR
607
			)
608
	);
609
610
	/**
611
	 * Redefine protected constructor to add address description as dynamic property
612
	 */
613 13
	protected function __construct(array $data = array(), array $customOptions = array()) 
614
	{
615 13
		parent::__construct($data, $customOptions);
616 13
		$this->addAddressDescription();
617 13
	}
618
	
619
	
620
	/**
621
	 * If not existing, create an address description as a normalized address from following data properties:
622
	 * 		'addressLocality',
623
	 * 		'addressRegion',
624
	 * 		'streetAddress',
625
	 * 		'postalCode',
626
	 */
627 13
	private function addAddressDescription()
628
	{	
629 13
		extract($this->data);
630
631 13
		if(empty($addressDescription)){
632 10
			if( !empty($streetAddress) && ( !empty($addressLocality) || !empty($postalCode))){
633 4
				$addressDescription = "$streetAddress ,";
634 4
				if(!empty($postalCode)) { $addressDescription.= " $postalCode";}
635 4
				if(!empty($addressLocality)) { $addressDescription.= " $addressLocality"; }
636 4
				if(!empty($addressRegion)) { $addressDescription.= " ($addressRegion)"; }
637
			} else {
638 6
				$addressDescription = null;
639
			}
640
		}
641
		
642 13
		$addressDescription = \BOTK\Filters::FILTER_SANITIZE_ADDRESS($addressDescription);
643
		
644 13
		if(!empty($addressDescription)){
645 7
			$this->data['addressDescription']=$addressDescription;
646
		}
647 13
	}
648
	
649
	
650 4
	public function asTurtleFragment()
651
	{
652 4
		if(is_null($this->rdf)) {
653 4
			extract($this->data);
654
655
			//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...
656
657
			// create uris
658 4
			$organizationUri = $this->getUri();
659 4
			$addressUri = $organizationUri.'_address';
660 4
			$geoUri = ( !empty($lat) && !empty($long) )?"geo:$lat,$long":null;
661
			
662 4
			$tripleCounter =0;
663 4
			$turtleString='';
664
			
665
			// define $_ as a macro to write simple rdf
666 4
			$_= function($format, $var,$sanitize=true) use(&$turtleString, &$tripleCounter){
667 4
				foreach((array)$var as $v){
668 4
					if($var){
669 4
						$turtleString.= sprintf($format,$sanitize?\BOTK\Filters::FILTER_SANITIZE_TURTLE_STRING($v):$v);
670 4
						$tripleCounter++;
671
					}
672
				}
673 4
			};
674
675
	 		// serialize schema:LocalBusiness
676
			$_('<%s> a schema:LocalBusiness;', $organizationUri);	
677
			$uriVars= array(
678
				'parentOrganization' => 'schema:parentOrganization',
679
				'page' => 'foaf:page',
680
				'email' => 'schema:email',
681
				'homepage' => 'foaf:homepage',
682
				'geoUri' => 'schema:geo',
683
				'$hasMap' => 'schema:hasMap',
684
			);
685
			foreach ($uriVars as $uriVar => $property) {
686
				if(!empty($this->data[$uriVar])){
687
					$_("$property <%s>;", $this->data[$uriVar],false);	
688
				}
689
			}
690
			
691
			$stringVars= array(
692
				'businessType' => 'a',
693
				'id' => 'dct:identifier',
694
				'vatID' => 'schema:vatID',
695
				'taxtID' => 'schema:taxtID',
696
				'legalName' => 'schema:legalName',
697
				'businessName' => 'schema:alternateName',
698
				'telephone' => 'schema:telephone',
699
				'faxNumber' => 'schema:faxNumber',
700
				'openingHours' => 'schema:openingHours ',
701
				'disambiguatingDescription' => 'schema:disambiguatingDescription',
702
				'ateco2007' => 'botk:ateco2007',
703
				'naceV2' => 'botk:naceV2',
704
				'isicV4' => 'schema:isicV4',
705
				'hasServerManufacturer' => 'botk:hasServerManufacturer',
706
				'hasServerVirtualizationManufacturer' => 'botk:hasServerVirtualizationManufacturer',
707
				'hasDASManufacturer' => 'botk:hasDASManufacturer',
708
				'hasNASManufacturer' => 'botk:hasNASManufacturer',
709
				'hasSANManufacturer' => 'botk:hasSANManufacturer',
710
				'hasTapeLibraryManufacturer' => 'botk:hasTapeLibraryManufacturer',
711
				'hasStorageVirtualizationManufacturer' => 'botk:hasStorageVirtualizationManufacturer',
712
				'naics' => 'botk:naics',
713
				'hasNAFCode' => 'botk:hasNAFCode',
714
				'hasServerSeries' => 'botk:hasServerSeries',
715
				'hasDesktopManufacturer' => 'botk:hasDesktopManufacturer',
716
				'hasLaptopManufacturer' => 'botk:hasLaptopManufacturer',
717
				'hasDesktopVirtualizationManufacturer' => 'botk:hasDesktopVirtualizationManufacturer',
718
				'hasWorkstationManufacturer' => 'botk:hasWorkstationManufacturer',
719
				'hasNetworkPrinterManufacturer' => 'botk:hasNetworkPrinterManufacturer',
720
				'hasHighVolumePrinterManufacturer' => 'botk:hasHighVolumePrinterManufacturer',
721
				'hasCopierManufacturer' => 'botk:hasCopierManufacturer',
722
				'hasUPSManufacturer' => 'botk:hasUPSManufacturer',
723
				'hasERPSuiteVendor' => 'botk:hasERPSuiteVendor',
724
				'hasERPSoftwareasaServiceManufacturer' => 'botk:hasERPSoftwareasaServiceManufacturer',
725
				'hasAppServerSoftwareVendor' => 'botk:hasAppServerSoftwareVendor',
726
				'hasBusIntellSoftwareVendor' => 'botk:hasBusIntellSoftwareVendor',
727
				'hasCollaborativeSoftwareVendor' => 'botk:hasCollaborativeSoftwareVendor',
728
				'hasCRMSoftwareVendor' => 'botk:hasCRMSoftwareVendor',
729
				'hasCRMSoftwareasaServiceManufacturer' => 'botk:hasCRMSoftwareasaServiceManufacturer',
730
				'hasDocumentMgmtSoftwareVendor' => 'botk:hasDocumentMgmtSoftwareVendor',
731
				'hasAppConsolidationSoftwareVendor' => 'botk:hasAppConsolidationSoftwareVendor',
732
				'hasHumanResourceSoftwareVendor' => 'botk:hasHumanResourceSoftwareVendor',
733
				'hasSupplyChainSoftwareVendor' => 'botk:hasSupplyChainSoftwareVendor',
734
				'hasWebServiceSoftwareVendor' => 'botk:hasWebServiceSoftwareVendor',
735
				'hasDatawarehouseSoftwareVendor' => 'botk:hasDatawarehouseSoftwareVendor',
736
				'hasSaaSVendor' => 'botk:hasSaaSVendor',
737
				'hasEmailMessagingVendor' => 'botk:hasEmailMessagingVendor',
738
				'hasEmailSaaSManufacturer' => 'botk:hasEmailSaaSManufacturer',
739
				'hasOSVendor' => 'botk:hasOSVendor',
740
				'hasOSModel' => 'botk:hasOSModel',
741
				'hasDBMSVendor' => 'botk:hasDBMSVendor',
742
				'hasAcctingVendor' => 'botk:hasAcctingVendor',
743
				'hasAntiVirusVendor' => 'botk:hasAntiVirusVendor',
744
				'hasAssetManagementSoftwareVendor' => 'botk:hasAssetManagementSoftwareVendor',
745
				'hasEnterpriseManagementSoftwareVendor' => 'botk:hasEnterpriseManagementSoftwareVendor',
746
				'hasIDAccessSoftwareVendor' => 'botk:hasIDAccessSoftwareVendor',
747
				'hasStorageManagementSoftwareVendor' => 'botk:hasStorageManagementSoftwareVendor',
748
				'hasStorageSaaSManufacturer' => 'botk:hasStorageSaaSManufacturer',
749
				'hasEthernetTechnology' => 'botk:hasEthernetTechnology',
750
				'haseCommerceType' => 'botk:haseCommerceType',
751
				'hasHostorRemoteStatus' => 'botk:hasHostorRemoteStatus',
752
				'hasNetworkLineCarrier' => 'botk:hasNetworkLineCarrier',
753
				'hasVideoConfServicesProvider' => 'botk:hasVideoConfServicesProvider',
754
				'hasUnifiedCommSvcProvider' => 'botk:hasUnifiedCommSvcProvider',
755
				'hasRouterManufacturer' => 'botk:hasRouterManufacturer',
756
				'hasSwitchManufacturer' => 'botk:hasSwitchManufacturer',
757
				'hasVPNManufacturer' => 'botk:hasVPNManufacturer',
758
				'hasISP' => 'botk:hasISP',
759
				'hasNetworkServiceProvider' => 'botk:hasNetworkServiceProvider',
760
				'hasPhoneSystemManufacturer' => 'botk:hasPhoneSystemManufacturer',
761
				'hasVoIPManufacturer' => 'botk:hasVoIPManufacturer',
762
				'hasVoIPHosting' => 'botk:hasVoIPHosting',
763
				'hasLongDistanceCarrier' => 'botk:hasLongDistanceCarrier',
764
				'hasWirelessProvider' => 'botk:hasWirelessProvider',
765
				'hasPhoneSystemMaintenanceProvider' => 'botk:hasPhoneSystemMaintenanceProvider',
766
				'hasSmartphoneManufacturer' => 'botk:hasSmartphoneManufacturer',
767
				'hasSmartphoneOS' => 'botk:hasSmartphoneOS',
768
				'hasFYE'=> 'botk:hasFYE',
769
			);
770
			foreach ($stringVars as $stringVar => $property) {
771
				if(!empty($this->data[$stringVar])){
772
					$_("$property \"%s\";", $this->data[$stringVar]);	
773
				}
774
			}
775
			$_('schema:address <%s>. ', $addressUri);
776
			
777
			// serialize schema:PostalAddress 
778
			$_('<%s> a schema:PostalAddress;', $addressUri);
779
			!empty($addressDescription) && $_('schema:description "%s";', $addressDescription);
780
			!empty($streetAddress) 		&& $_('schema:streetAddress "%s";', $streetAddress);
781
			!empty($postalCode) 		&& $_('schema:postalCode "%s";', $postalCode);
782
			!empty($addressLocality) 	&& $_('schema:addressLocality "%s";', $addressLocality);
783
			!empty($addressRegion) 		&& $_('schema:addressRegion "%s";', $addressRegion);
784
			$_('schema:addressCountry "%s". ', $addressCountry);	
785
			
786
			
787
			$statVars = array(
788
				'numberOfEmployees' => 'schema:numberOfEmployees',
789
				'annualTurnover' => 'botk:annualTurnover',
790
				'ebitda' => 'botk:ebitda' ,
791
				'netProfit' => 'botk:netProfit',
792
				'hasTotDevelopers' => 'botk:hasTotDevelopers',
793
				'itBudget' => 'botk:itBudget',
794
				'itStorageBudget' => 'botk:itStorageBudget',
795
				'itHardwareBudget' => 'botk:itHardwareBudget',
796
				'itServerBudget' => 'botk:itServerBudget',
797
				'softwareBudget' => 'botk:softwareBudget',				
798
				'hasITEmployees' => 'botk:hasITEmployees',
799
				'hasNumberOfPCs' => 'botk:hasNumberOfPCs',
800
				'hasITBudget' => 'botk:hasITBudget',
801
				'hasTablets' => 'botk:hasTablets',
802
				'hasWorkstations' => 'botk:hasWorkstations',
803
				'hasStorageBudget' => 'botk:hasStorageBudget',
804
				'hasServerBudget' => 'botk:hasServerBudget',
805
				'hasServers' => 'botk:hasServers',
806
				'hasDesktop' => 'botk:hasDesktop',
807
				'hasLaptops' => 'botk:hasLaptops',
808
				'hasPrinters' => 'botk:hasPrinters',
809
				'hasMultifunctionPrinters' => 'botk:hasMultifunctionPrinters',
810
				'hasColorPrinter' => 'botk:hasColorPrinter',
811
				'hasInternetUsers' => 'botk:hasInternetUsers',
812
				'hasWirelessUsers' => 'botk:hasWirelessUsers',
813
				'hasNetworkLines' => 'botk:hasNetworkLines',
814
				'hasRouters' => 'botk:hasRouters',
815
				'hasStorageCapacity' => 'botk:hasStorageCapacity',
816
				'hasExtensions' => 'botk:hasExtensions',
817
				'hasTotCallCenterCallers' => 'botk:hasTotCallCenterCallers',
818
				'hasThinPC' => 'botk:hasThinPC',
819
				'hasSalesforce' => 'botk:hasSalesforce',
820
				'hasRevenue' => 'botk:hasRevenue',
821
				'hasCommercialBudget' => 'botk:hasCommercialBudget',
822
				'hasHardwareBudget' => 'botk:hasHardwareBudget',
823
				'hasSoftwareBudget' => 'botk:hasSoftwareBudget',
824
				'hasOutsrcingBudget' => 'botk:hasOutsrcingBudget',
825
				'hasOtherHardwareBudget' => 'botk:hasOtherHardwareBudget',
826
				'hasPCBudget' => 'botk:hasPCBudget',
827
				'hasPrinterBudget' => 'botk:hasPrinterBudget',
828
				'hasTerminalBudget' => 'botk:hasTerminalBudget',
829
				'hasPeripheralBudget' => 'botk:hasPeripheralBudget',
830
				'hasDesktopPrinters' => 'botk:hasDesktopPrinters',
831
				'hasNetworkPrinters' => 'botk:hasNetworkPrinters',
832
				'hasSmartphoneUsers' => 'botk:hasSmartphoneUsers',
833
				'hasEnterpriseSmartphoneUsers'				
834
				);
835
			foreach ( $statVars as $statVar => $property){
836
				if(!empty($this->data[$statVar])&& ($range=\BOTK\Filters::PARSE_QUANTITATIVE_VALUE($this->data[$statVar])) ){
837
					list($min,$max)=$range;
838
					if( $min===$max){
839
						$statUri =  "<{$base}{$min}>";			
840
						$turtleString.= "<$organizationUri> $property $statUri .$statUri schema:value $min .";	
841
						$tripleCounter +=3;					
842
					} else {
843
						$statUri =  "<{$base}{$min}to{$max}>";			
844
						$turtleString.= "<$organizationUri> $property $statUri .$statUri schema:minValue $min ;schema:maxValue $max .";	
845
						$tripleCounter +=4;											
846
					}
847
				}		
848
			}
849
850
			// serialize schema:GeoCoordinates
851
			if( !empty($geoUri)){
852
				$_('<%s> a schema:GeoCoordinates;', $geoUri); 
853
				$_('wgs:lat "%s"^^xsd:float;', $lat);
854
				$_('wgs:long "%s"^^xsd:float . ', $long); 
855
			}
856
857
			$this->rdf = $turtleString;
858
			$this->tripleCount = $tripleCounter;
859
		}
860
861
		return $this->rdf;
862
	}
863
864
}