@@ -856,28 +856,7 @@ protected function _mapFnToApiMethod($function, &$apiparams)
856856 $ method = $ this ->_mapFnRestoreParamUnderscores ($ method );
857857
858858 // replace AA by URL parameters
859- $ method_template = $ method ;
860- $ match = [];
861- if (preg_match_all ('/[A-Z_]{2,}/ ' , $ method , $ match )) {
862- foreach ($ match [0 ] as $ param ) {
863- $ param_l = strtolower ($ param );
864- if ($ param_l === 'resumeid ' ) {
865- $ param_l = 'resumeId ' ;
866- }
867- $ method_template = str_replace ($ param , ': ' . $ param_l , $ method_template );
868- if (! isset ($ apiparams [$ param_l ])) {
869- for ($ i = 0 ; $ i < 26 ; $ i ++) {
870- $ method_template = str_replace (chr (65 + $ i ), '_ ' . chr (97 + $ i ), $ method_template );
871- }
872- throw new \Exception (
873- 'To call the templated method " ' . $ method_template
874- . '", specify the parameter value for " ' . $ param_l . '". '
875- );
876- }
877- $ method = str_replace ($ param , $ apiparams [$ param_l ], $ method );
878- unset($ apiparams [$ param_l ]);
879- }
880- }
859+ list ($ method , $ method_template ) = $ this ->_mapFnInlineParams ($ method , $ apiparams );
881860
882861 if (substr ($ method , 0 , 4 ) !== 'ton/ ' ) {
883862 // replace A-Z by _a-z
@@ -925,6 +904,42 @@ protected function _mapFnRestoreParamUnderscores($method)
925904 return $ method ;
926905 }
927906
907+ /**
908+ * Inserts inline parameters into the method name
909+ *
910+ * @param string $method The method to call
911+ * @param array byref $apiparams The parameters to send along
912+ *
913+ * @return string[] (string method, string method_template)
914+ */
915+ protected function _mapFnInlineParams ($ method , &$ apiparams )
916+ {
917+ $ method_template = $ method ;
918+ $ match = [];
919+ if (preg_match_all ('/[A-Z_]{2,}/ ' , $ method , $ match )) {
920+ foreach ($ match [0 ] as $ param ) {
921+ $ param_l = strtolower ($ param );
922+ if ($ param_l === 'resumeid ' ) {
923+ $ param_l = 'resumeId ' ;
924+ }
925+ $ method_template = str_replace ($ param , ': ' . $ param_l , $ method_template );
926+ if (! isset ($ apiparams [$ param_l ])) {
927+ for ($ i = 0 ; $ i < 26 ; $ i ++) {
928+ $ method_template = str_replace (chr (65 + $ i ), '_ ' . chr (97 + $ i ), $ method_template );
929+ }
930+ throw new \Exception (
931+ 'To call the templated method " ' . $ method_template
932+ . '", specify the parameter value for " ' . $ param_l . '". '
933+ );
934+ }
935+ $ method = str_replace ($ param , $ apiparams [$ param_l ], $ method );
936+ unset($ apiparams [$ param_l ]);
937+ }
938+ }
939+
940+ return [$ method , $ method_template ];
941+ }
942+
928943
929944 /**
930945 * Uncommon API methods
0 commit comments