22
33namespace DocumentPHP ;
44
5- include_once getcwd () . '../../../../system/engine/controller.php ' ;
6-
7- error_reporting (E_ALL ^ E_NOTICE ^ E_WARNING );
5+ include_once getcwd () . '/system/engine/controller.php ' ;
86
97class FetchFiles {
10- public $ data = [];
11- public $ destination_path = getcwd () . '../../../../catalog/controller/api/ ' ;
12-
13- function rrmdir ($ dir ) {
14- // return;
15- if (is_dir ($ dir )) {
16- $ objects = scandir ($ dir );
8+ private $ results = [];
9+ private $ destination_path = '' ;
1710
18- foreach ($ objects as $ object ) {
19- if ($ object != '. ' && $ object != '.. ' ) {
20- if (filetype ($ dir . '/ ' . $ object ) == 'dir ' ) {$ this ->rrmdir ($ dir . '/ ' . $ object );} else {unlink ($ dir . '/ ' . $ object );}
21- }
22- }
11+ public function getResults () {
12+ return $ this ->results ;
13+ }
2314
24- reset ($ objects );
25- // rmdir($dir);
15+ public function setDestinationPath ($ path = '' ) {
16+ if ($ path ) {
17+ $ this ->destination_path = $ path ;
18+ } else {
19+ $ this ->destination_path = getcwd () . '/catalog/controller/api/ ' ;
2620 }
2721 }
2822
29- function recursive_copy ($ src, $ dst ) {
23+ private function recursive_copy ($ src ) {
3024 if (is_dir ($ src )) {
3125 $ dir = opendir ($ src );
3226
3327 while (($ file = readdir ($ dir ))) {
3428 if ((substr ($ file , -1 ) != '_ ' ) && ($ file != '. ' ) && ($ file != '.. ' )) {
3529 if (is_dir ($ src . '/ ' . $ file )) {
36- $ this ->recursive_copy ($ src . '/ ' . $ file, $ dst . ' / ' . $ file );
30+ $ this ->recursive_copy ($ src . '/ ' . $ file );
3731 } else {
3832 if (is_file ($ this ->destination_path . $ file )) {
39- $ this ->start_processing ($ this ->destination_path . $ file );
33+ $ this ->start_fetching ($ this ->destination_path . $ file );
4034 // print_r($this->destination_path . $file);
4135 }
42- // die;
43- // copy($src . '/' . $file, $dst . '/' . $file);
4436 }
4537 }
4638 }
4739 closedir ($ dir );
4840
4941 return ;
5042 } elseif (is_file ($ src )) {
51- $ dir = substr ($ dst , 0 , strrpos ($ dst , '/ ' ));
52- // mkdir($dir, 0777, true);
53-
54- print_r ($ src );die;
55- // copy($src, $dst);
5643 } else {
5744 die ('<strong>Not found : </strong> ' . $ src );
5845 // print_r($src);die;
5946 }
6047 }
6148
62- function get_function ($ method , $ class = null ) {
49+ private function get_function ($ method , $ class = null ) {
6350
6451 if (!empty ($ class )) {
65- $ func = new ReflectionMethod ($ class , $ method );
52+ $ func = new \ ReflectionMethod ($ class , $ method );
6653 } else {
6754 $ func = new ReflectionFunction ($ method );
6855 }
@@ -84,7 +71,12 @@ function get_function($method, $class = null) {
8471 return $ body ;
8572 }
8673
87- function start_processing ($ file ) {
74+ public function start_processing ($ path = '' ) {
75+ $ this ->setDestinationPath ($ path );
76+ $ this ->recursive_copy ($ this ->destination_path );
77+ }
78+
79+ private function start_fetching ($ file ) {
8880 include_once $ file ;
8981
9082 $ start = strpos ($ file , 'controller ' ) + strlen ('controller ' );
@@ -116,24 +108,25 @@ function start_processing($file) {
116108 }
117109 }
118110
119- $ this ->data [$ class_name ] = $ current_data ;
120- // print_r($this->data );
111+ $ this ->results [$ class_name ] = $ current_data ;
112+ // print_r($this->results );
121113 // echo "</pre>";
122114 }
123115
124- function findMethodTypesVars ($ function_string = '' ) {
116+ private function findMethodTypesVars ($ function_string = '' ) {
125117 $ method_types = [];
126118 $ method_types ['POST ' ] = $ this ->getParams ($ function_string , "/->post\[/i " , ['->post[ ' , '\'' ], '' );
127119 $ method_types ['GET ' ] = $ this ->getParams ($ function_string , "/->get\[/i " , ['->get[ ' , '\'' ], '' );
128120 return $ method_types ;
129121 }
130122
131- function isReturningJSONResponse ($ function_string = '' ) {
123+ private function isReturningJSONResponse ($ function_string = '' ) {
132124 preg_match_all ("/setOutput\(/i " , $ function_string , $ matches );
133125
134126 return !empty ($ matches [0 ]) ? true : false ;
135127 }
136- function getParams ($ function_string , $ pattern , $ find , $ replace = '' ) {
128+
129+ private function getParams ($ function_string , $ pattern , $ find , $ replace = '' ) {
137130 preg_match_all ($ pattern , $ function_string , $ matches , PREG_OFFSET_CAPTURE );
138131
139132 $ var_names = [];
0 commit comments