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 |
||
34 | private function fixPath($app = 'application', $pub = 'public') |
||
35 | { |
||
36 | $file = $app . '/' . static::TEST_FOLDER . '/Bootstrap.php'; |
||
37 | $contents = file_get_contents($file); |
||
38 | |||
39 | if (! file_exists('system')) { |
||
40 | if (file_exists('vendor/codeigniter/framework/system')) { |
||
41 | $contents = str_replace( |
||
42 | '$system_path = \'../../system\';', |
||
43 | '$system_path = \'../../vendor/codeigniter/framework/system\';', |
||
44 | $contents |
||
45 | ); |
||
46 | } else { |
||
47 | throw new Exception('Can\'t find "system" folder.'); |
||
48 | } |
||
49 | } |
||
50 | |||
51 | if (! file_exists('index.php')) { |
||
52 | if (file_exists($pub . '/index.php')) { |
||
53 | // CodeIgniter 3.0.6 and after |
||
54 | $contents = str_replace( |
||
55 | "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", |
||
56 | "define('FCPATH', realpath(dirname(__FILE__).'/../../'. $pub).DIRECTORY_SEPARATOR);", |
||
57 | $contents |
||
58 | ); |
||
59 | // CodeIgniter 3.0.5 and before |
||
60 | $contents = str_replace( |
||
61 | "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');", |
||
62 | "define('FCPATH', realpath(dirname(__FILE__).'/../../' . $pub).'/');", |
||
63 | $contents |
||
64 | ); |
||
65 | } elseif (file_exists($app . '/public/index.php')) { |
||
66 | // CodeIgniter 3.0.6 and after |
||
67 | $contents = str_replace( |
||
68 | "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", |
||
69 | "define('FCPATH', realpath(dirname(__FILE__).'/../public').DIRECTORY_SEPARATOR);", |
||
70 | $contents |
||
71 | ); |
||
72 | // CodeIgniter 3.0.5 and before |
||
73 | $contents = str_replace( |
||
74 | "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');", |
||
75 | "define('FCPATH', realpath(dirname(__FILE__).'/../public').'/');", |
||
76 | $contents |
||
77 | ); |
||
78 | if ($app != 'application') { |
||
79 | $contents = str_replace( |
||
80 | "\$application_folder = '../../application';", |
||
81 | "\$application_folder = '../../{$app}';", |
||
82 | $contents |
||
83 | ); |
||
84 | } |
||
85 | } else { |
||
86 | throw new Exception('Can\'t find "index.php".'); |
||
87 | } |
||
88 | } |
||
89 | |||
90 | file_put_contents($file, $contents); |
||
91 | } |
||
92 | |||
155 |
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.