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 |
||
81 | private function fixPath() |
||
82 | { |
||
83 | $file = $this->app . '/' . static::TEST_FOLDER . '/Bootstrap.php'; |
||
84 | $contents = file_get_contents($file); |
||
85 | |||
86 | if (! file_exists('system')) { |
||
87 | if (file_exists('vendor/codeigniter/framework/system')) { |
||
88 | $contents = str_replace( |
||
89 | '$system_path = \'../../system\';', |
||
90 | '$system_path = \'../../vendor/codeigniter/framework/system\';', |
||
91 | $contents |
||
92 | ); |
||
93 | } else { |
||
94 | throw new Exception('Can\'t find "system" folder.'); |
||
95 | } |
||
96 | } |
||
97 | |||
98 | if (! file_exists('index.php')) { |
||
99 | if (file_exists($pub . '/index.php')) { |
||
100 | // CodeIgniter 3.0.6 and after |
||
101 | $contents = str_replace( |
||
102 | "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", |
||
103 | "define('FCPATH', realpath(dirname(__FILE__).'/../../'. $pub).DIRECTORY_SEPARATOR);", |
||
104 | $contents |
||
105 | ); |
||
106 | // CodeIgniter 3.0.5 and before |
||
107 | $contents = str_replace( |
||
108 | "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');", |
||
109 | "define('FCPATH', realpath(dirname(__FILE__).'/../../' . $pub).'/');", |
||
110 | $contents |
||
111 | ); |
||
112 | } elseif (file_exists($this->app . '/public/index.php')) { |
||
113 | // CodeIgniter 3.0.6 and after |
||
114 | $contents = str_replace( |
||
115 | "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", |
||
116 | "define('FCPATH', realpath(dirname(__FILE__).'/../public').DIRECTORY_SEPARATOR);", |
||
117 | $contents |
||
118 | ); |
||
119 | // CodeIgniter 3.0.5 and before |
||
120 | $contents = str_replace( |
||
121 | "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');", |
||
122 | "define('FCPATH', realpath(dirname(__FILE__).'/../public').'/');", |
||
123 | $contents |
||
124 | ); |
||
125 | if ($this->app != 'application') { |
||
126 | $contents = str_replace( |
||
127 | "\$application_folder = '../../application';", |
||
128 | "\$application_folder = '../../{$this->app}';", |
||
129 | $contents |
||
130 | ); |
||
131 | } |
||
132 | } else { |
||
133 | throw new Exception('Can\'t find "index.php".'); |
||
134 | } |
||
135 | } |
||
136 | |||
137 | file_put_contents($file, $contents); |
||
138 | } |
||
139 | |||
202 |
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.