Conditions | 4 |
Paths | 5 |
Total Lines | 51 |
Code Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
80 | public function get($params) |
||
81 | { |
||
82 | list($table,$name,$type) = $params; |
||
83 | |||
84 | $results = []; |
||
85 | |||
86 | $paths = $this->getPaths($params); |
||
87 | |||
88 | foreach ($paths as $pathKey=>$path){ |
||
89 | |||
90 | $tableDirectory = $path.'/'.ucfirst($table); |
||
91 | |||
92 | |||
93 | if(!file_exists($tableDirectory)){ |
||
94 | $results['directory'][$pathKey]= $this->fileProcess($tableDirectory,'makeDirectory'); |
||
95 | } |
||
96 | else{ |
||
97 | $results['directory'][$pathKey]= $this->getResult(false, |
||
98 | 'Already exist the specified directory'); |
||
99 | } |
||
100 | |||
101 | $results['directory'][$pathKey]['table']= $table; |
||
102 | $results['directory'][$pathKey]['directory']= $table; |
||
103 | $results['directory'][$pathKey]['type']= $type; |
||
104 | |||
105 | $fileName = ucfirst($name); |
||
106 | |||
107 | $fileNameWithTime = time().'_'.$fileName; |
||
108 | |||
109 | $filePath = $tableDirectory.'/'.$fileNameWithTime.'.php'; |
||
110 | |||
111 | if(!file_exists($filePath)){ |
||
112 | $results['file'][$pathKey]=$this->fileProcess($filePath,'makeFile'); |
||
113 | } |
||
114 | else{ |
||
115 | $results['file'][$pathKey]= $this->getResult(false, |
||
116 | 'Already exist the specified file'); |
||
117 | } |
||
118 | |||
119 | $results['file'][$pathKey]['table']=$table; |
||
120 | $results['file'][$pathKey]['file']=$fileName; |
||
121 | $results['file'][$pathKey]['type']=$type; |
||
122 | |||
123 | $stubber = $this->stubber.'/'.$type.'.stub'; |
||
124 | |||
125 | $this->fopenprocess($stubber,$filePath,['className'=>$fileName]); |
||
126 | |||
127 | $this->file->chmod($tableDirectory,0777,000,true); |
||
128 | } |
||
129 | |||
130 | return $results; |
||
131 | } |
||
180 |