| Conditions | 19 |
| Paths | 486 |
| Total Lines | 98 |
| Code Lines | 49 |
| 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 |
||
| 23 | public function main () { |
||
| 24 | |||
| 25 | $subdomains = array(); |
||
| 26 | |||
| 27 | $this->clear(); |
||
| 28 | |||
| 29 | $this->helper('Multidimensional/Subdomains.Header')->output(); |
||
|
1 ignored issue
–
show
|
|||
| 30 | |||
| 31 | $first_run = Configure::check('Multidimensional/Subdomains.subdomains') ? false : true; |
||
| 32 | |||
| 33 | if ($first_run === false) { |
||
| 34 | |||
| 35 | $subdomains = Configure::consume('Multidimensional/Subdomains.subdomains'); |
||
| 36 | |||
| 37 | if (count($subdomains) == 0) { |
||
| 38 | $first_run = true; |
||
| 39 | } |
||
| 40 | |||
| 41 | } |
||
| 42 | |||
| 43 | if ((($first_run) ? (strtolower($this->in('Install Subdomains Plugin?', ['y', 'n'])) == 'y') : (strtolower($this->in('Update Configuration?', ['y', 'n'])) == 'y'))) { |
||
| 44 | |||
| 45 | do { |
||
| 46 | |||
| 47 | $addMore = true; |
||
| 48 | |||
| 49 | if ($first_run === false && $this->_countSubdomains($subdomains)) { |
||
| 50 | |||
| 51 | $subdomains = array_values(array_unique($subdomains)); |
||
| 52 | |||
| 53 | $subdomains = $this->_modifyArray($subdomains); |
||
| 54 | |||
| 55 | $this->_currentSubdomains($subdomains); |
||
| 56 | |||
| 57 | $addMore = $this->_askAddSubdomain(); |
||
| 58 | |||
| 59 | } |
||
| 60 | |||
| 61 | if ($addMore) { |
||
| 62 | |||
| 63 | if (!$this->_countSubdomains($subdomains)) { |
||
| 64 | $this->out(); |
||
| 65 | $this->out('Add Your First Subdomain.'); |
||
| 66 | } |
||
| 67 | |||
| 68 | do { |
||
| 69 | |||
| 70 | $this->out(); |
||
| 71 | |||
| 72 | $subdomain = $this->in('Subdomain:'); |
||
| 73 | $valid = $this->_validateSubdomain($subdomain); |
||
| 74 | |||
| 75 | $this->out(); |
||
| 76 | |||
| 77 | if ($valid) { |
||
| 78 | $subdomains[] = $subdomain; |
||
| 79 | } else { |
||
| 80 | $this->err('Invalid Subdomain.'); |
||
| 81 | } |
||
| 82 | |||
| 83 | } while (!$valid || $this->_askAddSubdomain()); |
||
| 84 | |||
| 85 | } |
||
| 86 | |||
| 87 | $subdomains = array_values(array_unique($subdomains)); |
||
| 88 | |||
| 89 | $subdomains = $this->_modifyArray($subdomains); |
||
| 90 | |||
| 91 | $this->_currentSubdomains($subdomains); |
||
| 92 | |||
| 93 | while ($this->_countSubdomains($subdomains) && $this->_askDeleteSubdomain()) { |
||
| 94 | |||
| 95 | $this->out(); |
||
| 96 | $deleteKey = (int) $this->in('Enter Number to Delete:', array_keys($subdomains)); |
||
| 97 | |||
| 98 | $this->_deleteSubdomain($subdomains, $deleteKey); |
||
| 99 | |||
| 100 | } |
||
| 101 | |||
| 102 | Configure::write('Multidimensional/Subdomains.subdomains', array_values($subdomains)); |
||
| 103 | Configure::dump('subdomains', 'default', ['Multidimensional/Subdomains']); |
||
| 104 | |||
| 105 | if (!$this->_countSubdomains($subdomains)) { |
||
| 106 | $this->out(); |
||
| 107 | $this->err('No Subdomains Configured.', 2); |
||
| 108 | } |
||
| 109 | |||
| 110 | } while (count($subdomains) == 0 && $this->_askStartOver()); |
||
| 111 | |||
| 112 | $this->out(); |
||
| 113 | if ($this->_countSubdomains($subdomains)) { |
||
| 114 | $this->out('Configuration Saved!', 2); |
||
| 115 | } else { |
||
| 116 | $this->err('Plugin Not Currently Active.', 2); |
||
| 117 | } |
||
| 118 | } |
||
| 119 | |||
| 120 | } |
||
| 121 | |||
| 193 | } |
This check looks for function calls that miss required arguments.