| Conditions | 10 |
| Paths | 60 |
| Total Lines | 63 |
| 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 |
||
| 10 | public function __construct() |
||
| 11 | { |
||
| 12 | // Set host name |
||
| 13 | $host = $_SERVER['SERVER_NAME']; |
||
| 14 | |||
| 15 | // List of our development domains |
||
| 16 | $dev_domains = [ |
||
| 17 | 'localhost', |
||
| 18 | ]; |
||
| 19 | |||
| 20 | if (in_array($host, $dev_domains)) { |
||
| 21 | |||
| 22 | $this->env = 'development'; |
||
| 23 | |||
| 24 | // Set development ENV |
||
| 25 | if (!defined('WP_ENV')) { |
||
| 26 | define('WP_ENV', 'development'); |
||
| 27 | } |
||
| 28 | |||
| 29 | // Enable strict error reporting |
||
| 30 | error_reporting(E_ALL | E_STRICT); |
||
| 31 | @ini_set('display_errors', 1); |
||
| 32 | |||
| 33 | if (!defined('WP_DEBUG')) { |
||
| 34 | define('WP_DEBUG', true); |
||
| 35 | } |
||
| 36 | |||
| 37 | } else { |
||
| 38 | |||
| 39 | $this->env = 'production'; |
||
| 40 | |||
| 41 | // Set production ENV |
||
| 42 | if (!defined('WP_ENV')) { |
||
| 43 | define('WP_ENV', 'production'); |
||
| 44 | } |
||
| 45 | |||
| 46 | // Limit post revisions to 5. |
||
| 47 | if (!defined('WP_POST_REVISIONS')) { |
||
| 48 | define('WP_POST_REVISIONS', 5); |
||
| 49 | } |
||
| 50 | |||
| 51 | // disallow wp files editor. |
||
| 52 | if (!defined('DISALLOW_FILE_EDIT')) { |
||
| 53 | define('DISALLOW_FILE_EDIT', true); |
||
| 54 | } |
||
| 55 | |||
| 56 | if (!defined('WP_DEBUG')) { |
||
| 57 | define('WP_DEBUG', false); |
||
| 58 | } |
||
| 59 | |||
| 60 | } |
||
| 61 | |||
| 62 | if (!defined('WP_ENV')) { |
||
| 63 | |||
| 64 | // Fallback if WP_ENV isn't defined |
||
| 65 | // Used to check for 'development' or 'production' |
||
| 66 | if (!defined('WP_ENV')) { |
||
| 67 | define('WP_ENV', 'production'); |
||
| 68 | } |
||
| 69 | |||
| 70 | } |
||
| 71 | |||
| 72 | } |
||
| 73 | |||
| 95 |