| Conditions | 5 |
| Paths | 1 |
| Total Lines | 57 |
| Code Lines | 44 |
| 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 |
||
| 20 | static function admin_about_server_get () { |
||
| 21 | $Core = Core::instance(); |
||
| 22 | $L = Language::instance(); |
||
| 23 | $hhvm = defined('HHVM_VERSION'); |
||
| 24 | Page::instance()->json( |
||
| 25 | [ |
||
| 26 | 'operating_system' => php_uname('s').' '.php_uname('r').' '.php_uname('v'), |
||
| 27 | 'server_type' => static::admin_about_server_get_server_api(), |
||
| 28 | 'available_ram' => $hhvm ? '' : str_replace( |
||
| 29 | ['K', 'M', 'G'], |
||
| 30 | [" $L->KB", " $L->MB", " $L->GB"], |
||
| 31 | ini_get('memory_limit') |
||
| 32 | ), |
||
| 33 | 'php_extensions' => [ |
||
| 34 | 'openssl' => extension_loaded('openssl'), |
||
| 35 | 'curl' => extension_loaded('curl'), |
||
| 36 | 'apcu' => extension_loaded('apcu'), |
||
| 37 | 'memcached' => extension_loaded('memcached') |
||
| 38 | ], |
||
| 39 | 'main_db' => [ |
||
| 40 | 'type' => $Core->db_type, |
||
| 41 | 'version' => DB::instance()->server(), |
||
|
1 ignored issue
–
show
|
|||
| 42 | 'host' => $Core->db_host, |
||
| 43 | 'name' => $Core->db_name, |
||
| 44 | 'prefix' => $Core->db_prefix |
||
| 45 | ], |
||
| 46 | 'main_storage' => [ |
||
| 47 | 'type' => $Core->storage_type |
||
| 48 | ], |
||
| 49 | 'cache_engine' => $Core->cache_engine, |
||
| 50 | 'free_disk_space' => format_filesize(disk_free_space('./'), 2), |
||
| 51 | 'php_ini' => [ |
||
| 52 | 'allow_file_uploads' => (bool)ini_get('file_uploads'), |
||
| 53 | 'max_file_uploads' => (int)ini_get('max_file_uploads'), |
||
| 54 | 'upload_size_limit' => format_filesize( |
||
| 55 | str_replace( |
||
| 56 | ['K', 'M', 'G'], |
||
| 57 | [" $L->KB", " $L->MB", " $L->GB"], |
||
| 58 | ini_get('upload_max_filesize') |
||
| 59 | ) |
||
| 60 | ), |
||
| 61 | 'post_max_size' => format_filesize( |
||
| 62 | str_replace( |
||
| 63 | ['K', 'M', 'G'], |
||
| 64 | [" $L->KB", " $L->MB", " $L->GB"], |
||
| 65 | ini_get('post_max_size') |
||
| 66 | ) |
||
| 67 | ), |
||
| 68 | 'max_execution_time' => $hhvm ? '' : format_time(ini_get('max_execution_time')), |
||
| 69 | 'max_input_time' => $hhvm ? '' : format_time(ini_get('max_input_time')), |
||
| 70 | 'default_socket_timeout' => $hhvm ? '' : format_time(ini_get('default_socket_timeout')), |
||
| 71 | 'allow_url_fopen' => (bool)ini_get('allow_url_fopen'), |
||
| 72 | 'display_errors' => (bool)ini_get('display_errors'), |
||
| 73 | ] |
||
| 74 | ] |
||
| 75 | ); |
||
| 76 | } |
||
| 77 | /** |
||
| 110 |
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: