Code Duplication    Length = 22-26 lines in 4 locations

src/F2fpay/Base/Aop/AopClient.php 4 locations

@@ 782-803 (lines=22) @@
779
780
	}
781
782
	function parserJSONSignSource($request, $responseContent) {
783
784
		$apiName = $request->getApiMethodName();
785
		$rootNodeName = str_replace(".", "_", $apiName) . $this->RESPONSE_SUFFIX;
786
787
		$rootIndex = strpos($responseContent, $rootNodeName);
788
		$errorIndex = strpos($responseContent, $this->ERROR_RESPONSE);
789
790
791
		if ($rootIndex > 0) {
792
793
			return $this->parserJSONSource($responseContent, $rootNodeName, $rootIndex);
794
		} else if ($errorIndex > 0) {
795
796
			return $this->parserJSONSource($responseContent, $this->ERROR_RESPONSE, $errorIndex);
797
		} else {
798
799
			return null;
800
		}
801
802
803
	}
804
805
	function parserJSONSource($responseContent, $nodeName, $nodeIndex) {
806
		$signDataStartIndex = $nodeIndex + strlen($nodeName) + 2;
@@ 839-864 (lines=26) @@
836
837
	}
838
839
	function parserXMLSignSource($request, $responseContent) {
840
841
842
		$apiName = $request->getApiMethodName();
843
		$rootNodeName = str_replace(".", "_", $apiName) . $this->RESPONSE_SUFFIX;
844
845
846
		$rootIndex = strpos($responseContent, $rootNodeName);
847
		$errorIndex = strpos($responseContent, $this->ERROR_RESPONSE);
848
		//		$this->echoDebug("<br/>rootNodeName:" . $rootNodeName);
849
		//		$this->echoDebug("<br/> responseContent:<xmp>" . $responseContent . "</xmp>");
850
851
852
		if ($rootIndex > 0) {
853
854
			return $this->parserXMLSource($responseContent, $rootNodeName, $rootIndex);
855
		} else if ($errorIndex > 0) {
856
857
			return $this->parserXMLSource($responseContent, $this->ERROR_RESPONSE, $errorIndex);
858
		} else {
859
860
			return null;
861
		}
862
863
864
	}
865
866
	function parserXMLSource($responseContent, $nodeName, $nodeIndex) {
867
		$signDataStartIndex = $nodeIndex + strlen($nodeName) + 1;
@@ 983-1004 (lines=22) @@
980
	}
981
982
983
	private function parserEncryptJSONSignSource($request, $responseContent) {
984
985
		$apiName = $request->getApiMethodName();
986
		$rootNodeName = str_replace(".", "_", $apiName) . $this->RESPONSE_SUFFIX;
987
988
		$rootIndex = strpos($responseContent, $rootNodeName);
989
		$errorIndex = strpos($responseContent, $this->ERROR_RESPONSE);
990
991
992
		if ($rootIndex > 0) {
993
994
			return $this->parserEncryptJSONItem($responseContent, $rootNodeName, $rootIndex);
995
		} else if ($errorIndex > 0) {
996
997
			return $this->parserEncryptJSONItem($responseContent, $this->ERROR_RESPONSE, $errorIndex);
998
		} else {
999
1000
			return null;
1001
		}
1002
1003
1004
	}
1005
1006
1007
	private function parserEncryptJSONItem($responseContent, $nodeName, $nodeIndex) {
@@ 1047-1072 (lines=26) @@
1044
1045
	}
1046
1047
	private function parserEncryptXMLSignSource($request, $responseContent) {
1048
1049
1050
		$apiName = $request->getApiMethodName();
1051
		$rootNodeName = str_replace(".", "_", $apiName) . $this->RESPONSE_SUFFIX;
1052
1053
1054
		$rootIndex = strpos($responseContent, $rootNodeName);
1055
		$errorIndex = strpos($responseContent, $this->ERROR_RESPONSE);
1056
		//		$this->echoDebug("<br/>rootNodeName:" . $rootNodeName);
1057
		//		$this->echoDebug("<br/> responseContent:<xmp>" . $responseContent . "</xmp>");
1058
1059
1060
		if ($rootIndex > 0) {
1061
1062
			return $this->parserEncryptXMLItem($responseContent, $rootNodeName, $rootIndex);
1063
		} else if ($errorIndex > 0) {
1064
1065
			return $this->parserEncryptXMLItem($responseContent, $this->ERROR_RESPONSE, $errorIndex);
1066
		} else {
1067
1068
			return null;
1069
		}
1070
1071
1072
	}
1073
1074
	private function parserEncryptXMLItem($responseContent, $nodeName, $nodeIndex) {
1075