Conditions | 7 |
Paths | 11 |
Total Lines | 58 |
Code Lines | 38 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 | private function fixPath() |
||
81 | { |
||
82 | $file = $this->app_dir . '/' . $this->test_dir . '/Bootstrap.php'; |
||
83 | $contents = file_get_contents($file); |
||
84 | |||
85 | if (! file_exists('system')) { |
||
86 | if (file_exists('vendor/codeigniter/framework/system')) { |
||
87 | $contents = str_replace( |
||
88 | '$system_path = \'../../system\';', |
||
89 | '$system_path = \'../../vendor/codeigniter/framework/system\';', |
||
90 | $contents |
||
91 | ); |
||
92 | } else { |
||
93 | throw new Exception('Can\'t find "system" folder.'); |
||
94 | } |
||
95 | } |
||
96 | |||
97 | if (! file_exists('index.php')) { |
||
98 | if (file_exists($this->pub_dir . '/index.php')) { |
||
99 | // CodeIgniter 3.0.6 and after |
||
100 | $contents = str_replace( |
||
101 | "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", |
||
102 | "define('FCPATH', realpath(dirname(__FILE__).'/../../'. $this->pub_dir).DIRECTORY_SEPARATOR);", |
||
103 | $contents |
||
104 | ); |
||
105 | // CodeIgniter 3.0.5 and before |
||
106 | $contents = str_replace( |
||
107 | "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');", |
||
108 | "define('FCPATH', realpath(dirname(__FILE__).'/../../' . $this->pub_dir).'/');", |
||
109 | $contents |
||
110 | ); |
||
111 | } elseif (file_exists($this->app_dir . '/public/index.php')) { |
||
112 | // CodeIgniter 3.0.6 and after |
||
113 | $contents = str_replace( |
||
114 | "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", |
||
115 | "define('FCPATH', realpath(dirname(__FILE__).'/../public').DIRECTORY_SEPARATOR);", |
||
116 | $contents |
||
117 | ); |
||
118 | // CodeIgniter 3.0.5 and before |
||
119 | $contents = str_replace( |
||
120 | "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');", |
||
121 | "define('FCPATH', realpath(dirname(__FILE__).'/../public').'/');", |
||
122 | $contents |
||
123 | ); |
||
124 | if ($this->app_dir != 'application') { |
||
125 | $contents = str_replace( |
||
126 | "\$application_folder = '../../application';", |
||
127 | "\$application_folder = '../../{$this->app_dir}';", |
||
128 | $contents |
||
129 | ); |
||
130 | } |
||
131 | } else { |
||
132 | throw new Exception('Can\'t find "index.php".'); |
||
133 | } |
||
134 | } |
||
135 | |||
136 | file_put_contents($file, $contents); |
||
137 | } |
||
138 | |||
201 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.