Code Duplication    Length = 17-19 lines in 7 locations

mod/gc_api/lib/profile.php 7 locations

@@ 363-380 (lines=18) @@
360
				}
361
362
				break;
363
			case 'classification':
364
				$classificationData = json_decode(json_encode($value), true);
365
				if (!isset($classificationData['group'])&&!isset($classificationData['level'])) {
366
					$response['error'] = 4;
367
					$response['message'] = 'invalid data format - missing classification group and level';
368
					return $response;
369
				}
370
				if (!isset($classificationData['group'])||!isset($classificationData['level'])) {
371
					$response['error'] = 4;
372
					$response['message'] = 'invalid data format - missing classification group or level';
373
					return $response;
374
				}
375
376
				$user_entity->set('classification', json_encode($value));
377
				break;
378
			case 'department':
379
				$deptData = json_decode(json_encode($value), true);
380
				if (!isset($deptData['fr'])&&!isset($deptData['en'])) {
381
					$response['error'] = 4;
382
					$response['message'] = 'invalid data format - department format';
383
					return $response;
@@ 455-471 (lines=17) @@
452
					$user_entity->set('department', $deptData['en'].' / '.$deptData['fr']);
453
				}
454
				break;
455
			case 'branch':
456
				$branchData = json_decode(json_encode($value), true);
457
				if (!isset($branchData['en'])&&!isset($branchData['fr'])) {
458
					$response['error'] = 4;
459
					$response['message'] = 'invalid data format - missing english and french branch name';
460
					return $response;
461
				}
462
				if (!isset($branchData['en'])||!isset($branchData['fr'])) {
463
					$response['error'] = 4;
464
					$response['message'] = 'invalid data format - missing english or french branch name';
465
					return $response;
466
				}
467
468
				$user_entity->set('branch', json_encode($value));
469
				break;
470
			case 'sector':
471
				$sectorData = json_decode(json_encode($value), true);
472
				if (!isset($sectorData['en'])&&!isset($sectorData['fr'])) {
473
					$response['error'] = 4;
474
					$response['message'] = 'invalid data format - missing english and french sector name';
@@ 470-486 (lines=17) @@
467
468
				$user_entity->set('branch', json_encode($value));
469
				break;
470
			case 'sector':
471
				$sectorData = json_decode(json_encode($value), true);
472
				if (!isset($sectorData['en'])&&!isset($sectorData['fr'])) {
473
					$response['error'] = 4;
474
					$response['message'] = 'invalid data format - missing english and french sector name';
475
					return $response;
476
				}
477
				if (!isset($sectorData['en'])||!isset($sectorData['fr'])) {
478
					$response['error'] = 4;
479
					$response['message'] = 'invalid data format - missing english or french sector name';
480
					return $response;
481
				}
482
483
				$user_entity->set('sector', json_encode($value));
484
				break;
485
			case 'location':
486
				if (!isset($value['en'])) {
487
					$response['error'] = 4;
488
					$response['message'] = 'missing english location data';
489
					return $response;
@@ 622-640 (lines=19) @@
619
				$name = $nameData["firstName"].' '.$nameData["lastName"];
620
621
				break;
622
			case 'title':
623
624
				$titleData = json_decode(json_encode($value), true);
625
				if (!isset($titleData['fr'])&&!isset($titleData['en'])) {
626
					$response['error'] = 4;
627
					$response['message'] = 'invalid data format - missing french and english title';
628
					return $response;
629
				}
630
				if (!isset($titleData['fr'])||!isset($titleData['en'])) {
631
					$response['error'] = 4;
632
					$response['message'] = 'invalid data format - missing french or english title';
633
					return $response;
634
				}
635
				break;
636
			case 'classification':
637
				$classificationData = json_decode(json_encode($value), true);
638
				if (!isset($classificationData['group'])&&!isset($classificationData['level'])) {
639
					$response['error'] = 4;
640
					$response['message'] = 'invalid data format - missing classification group and level';
641
					return $response;
642
				}
643
				if (!isset($classificationData['group'])||!isset($classificationData['level'])) {
@@ 636-652 (lines=17) @@
633
					return $response;
634
				}
635
				break;
636
			case 'classification':
637
				$classificationData = json_decode(json_encode($value), true);
638
				if (!isset($classificationData['group'])&&!isset($classificationData['level'])) {
639
					$response['error'] = 4;
640
					$response['message'] = 'invalid data format - missing classification group and level';
641
					return $response;
642
				}
643
				if (!isset($classificationData['group'])||!isset($classificationData['level'])) {
644
					$response['error'] = 4;
645
					$response['message'] = 'invalid data format - missing classification group or level';
646
					return $response;
647
				}
648
649
				break;
650
			case 'department':
651
				$deptData = json_decode(json_encode($value), true);
652
				if (!isset($deptData['fr'])&&!isset($deptData['en'])) {
653
					$response['error'] = 4;
654
					$response['message'] = 'invalid data format - department format';
655
					return $response;
@@ 717-733 (lines=17) @@
714
					return $response;
715
				}
716
				break;
717
			case 'branch':
718
				$branchData = json_decode(json_encode($value), true);
719
				if (!isset($branchData['en'])&&!isset($branchData['fr'])) {
720
					$response['error'] = 4;
721
					$response['message'] = 'invalid data format - missing english and french branch name';
722
					return $response;
723
				}
724
				if (!isset($branchData['en'])||!isset($branchData['fr'])) {
725
					$response['error'] = 4;
726
					$response['message'] = 'invalid data format - missing english or french branch name';
727
					return $response;
728
				}
729
				break;
730
			case 'sector':
731
				$sectorData = json_decode(json_encode($value), true);
732
				if (!isset($sectorData['en'])&&!isset($sectorData['fr'])) {
733
					$response['error'] = 4;
734
					$response['message'] = 'invalid data format - missing english and french sector name';
735
					return $response;
736
				}
@@ 730-746 (lines=17) @@
727
					return $response;
728
				}
729
				break;
730
			case 'sector':
731
				$sectorData = json_decode(json_encode($value), true);
732
				if (!isset($sectorData['en'])&&!isset($sectorData['fr'])) {
733
					$response['error'] = 4;
734
					$response['message'] = 'invalid data format - missing english and french sector name';
735
					return $response;
736
				}
737
				if (!isset($sectorData['en'])||!isset($sectorData['fr'])) {
738
					$response['error'] = 4;
739
					$response['message'] = 'invalid data format - missing english or french sector name';
740
					return $response;
741
				}
742
				break;
743
			case 'location':
744
				if (!isset($value['en'])) {
745
					$response['error'] = 4;
746
					$response['message'] = 'missing english location data';
747
					return $response;
748
				}
749
				$locationData = json_decode(json_encode($value['en']), true);