@@ -155,6 +155,9 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | + /** |
|
| 159 | + * @param integer $key |
|
| 160 | + */ |
|
| 158 | 161 | private function _deleteSubdomain (&$subdomains, $key) { |
| 159 | 162 | |
| 160 | 163 | if (isset($subdomains[$key])) { |
@@ -168,6 +171,9 @@ discard block |
||
| 168 | 171 | |
| 169 | 172 | } |
| 170 | 173 | |
| 174 | + /** |
|
| 175 | + * @param string|null $subdomain |
|
| 176 | + */ |
|
| 171 | 177 | private function _validateSubdomain ($subdomain) { |
| 172 | 178 | |
| 173 | 179 | return preg_match('/^[A-Za-z0-9]{1}(?:[A-Za-z0-9\-]{0,61}[A-Za-z0-9]{1})?$/', $subdomain); |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | if ($first_run === false && $this->_countSubdomains($subdomains)) { |
| 50 | 50 | |
| 51 | - $subdomains = array_values(array_unique($subdomains)); |
|
| 51 | + $subdomains = array_values(array_unique($subdomains)); |
|
| 52 | 52 | |
| 53 | - $subdomains = $this->_modifyArray($subdomains); |
|
| 53 | + $subdomains = $this->_modifyArray($subdomains); |
|
| 54 | 54 | |
| 55 | - $this->_currentSubdomains($subdomains); |
|
| 55 | + $this->_currentSubdomains($subdomains); |
|
| 56 | 56 | |
| 57 | 57 | $addMore = $this->_askAddSubdomain(); |
| 58 | 58 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | if ($addMore) { |
| 62 | 62 | |
| 63 | 63 | if (!$this->_countSubdomains($subdomains)) { |
| 64 | - $this->out(); |
|
| 64 | + $this->out(); |
|
| 65 | 65 | $this->out('Add Your First Subdomain.'); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $this->out(); |
| 71 | 71 | |
| 72 | 72 | $subdomain = $this->in('Subdomain:'); |
| 73 | - $valid = $this->_validateSubdomain($subdomain); |
|
| 73 | + $valid = $this->_validateSubdomain($subdomain); |
|
| 74 | 74 | |
| 75 | 75 | $this->out(); |
| 76 | 76 | |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | $subdomains = $this->_modifyArray($subdomains); |
| 90 | 90 | |
| 91 | - $this->_currentSubdomains($subdomains); |
|
| 91 | + $this->_currentSubdomains($subdomains); |
|
| 92 | 92 | |
| 93 | 93 | while ($this->_countSubdomains($subdomains) && $this->_askDeleteSubdomain()) { |
| 94 | 94 | |
| 95 | 95 | $this->out(); |
| 96 | 96 | $deleteKey = (int) $this->in('Enter Number to Delete:', array_keys($subdomains)); |
| 97 | 97 | |
| 98 | - $this->_deleteSubdomain($subdomains, $deleteKey); |
|
| 98 | + $this->_deleteSubdomain($subdomains, $deleteKey); |
|
| 99 | 99 | |
| 100 | 100 | } |
| 101 | 101 | |
@@ -126,68 +126,68 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | |
| 129 | - private function _currentSubdomains (array $subdomains) { |
|
| 129 | + private function _currentSubdomains (array $subdomains) { |
|
| 130 | 130 | |
| 131 | - if ($this->_countSubdomains($subdomains)) { |
|
| 131 | + if ($this->_countSubdomains($subdomains)) { |
|
| 132 | 132 | |
| 133 | - $this->out(); |
|
| 134 | - $this->out('Current Subdomains:', 2); |
|
| 133 | + $this->out(); |
|
| 134 | + $this->out('Current Subdomains:', 2); |
|
| 135 | 135 | |
| 136 | - foreach ($subdomains AS $key => $value) { |
|
| 137 | - $this->out(' ' . ($key) . '. ' . $value); |
|
| 138 | - } |
|
| 136 | + foreach ($subdomains AS $key => $value) { |
|
| 137 | + $this->out(' ' . ($key) . '. ' . $value); |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - $this->out(); |
|
| 140 | + $this->out(); |
|
| 141 | 141 | |
| 142 | - } |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - } |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | - private function _askAddSubdomain () { |
|
| 146 | + private function _askAddSubdomain () { |
|
| 147 | 147 | |
| 148 | - return (strtolower($this->in('Add Subdomain?', ['y', 'n'])) === 'y'); |
|
| 148 | + return (strtolower($this->in('Add Subdomain?', ['y', 'n'])) === 'y'); |
|
| 149 | 149 | |
| 150 | - } |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - private function _askDeleteSubdomain () { |
|
| 152 | + private function _askDeleteSubdomain () { |
|
| 153 | 153 | |
| 154 | - return (strtolower($this->in('Delete Subdomain?', ['y', 'n'])) === 'y'); |
|
| 154 | + return (strtolower($this->in('Delete Subdomain?', ['y', 'n'])) === 'y'); |
|
| 155 | 155 | |
| 156 | - } |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - private function _deleteSubdomain (&$subdomains, $key) { |
|
| 158 | + private function _deleteSubdomain (&$subdomains, $key) { |
|
| 159 | 159 | |
| 160 | - if (isset($subdomains[$key])) { |
|
| 161 | - $this->out(); |
|
| 162 | - $this->out('Deleted: ' . $subdomains[$key], 2); |
|
| 163 | - unset($subdomains[$key]); |
|
| 164 | - return true; |
|
| 165 | - } |
|
| 160 | + if (isset($subdomains[$key])) { |
|
| 161 | + $this->out(); |
|
| 162 | + $this->out('Deleted: ' . $subdomains[$key], 2); |
|
| 163 | + unset($subdomains[$key]); |
|
| 164 | + return true; |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - return false; |
|
| 167 | + return false; |
|
| 168 | 168 | |
| 169 | - } |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | - private function _validateSubdomain ($subdomain) { |
|
| 171 | + private function _validateSubdomain ($subdomain) { |
|
| 172 | 172 | |
| 173 | - return preg_match('/^[A-Za-z0-9]{1}(?:[A-Za-z0-9\-]{0,61}[A-Za-z0-9]{1})?$/', $subdomain); |
|
| 173 | + return preg_match('/^[A-Za-z0-9]{1}(?:[A-Za-z0-9\-]{0,61}[A-Za-z0-9]{1})?$/', $subdomain); |
|
| 174 | 174 | |
| 175 | - } |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - private function _askStartOver () { |
|
| 177 | + private function _askStartOver () { |
|
| 178 | 178 | |
| 179 | - return (strtolower($this->in('Start Over?', ['y', 'n'])) === 'y'); |
|
| 179 | + return (strtolower($this->in('Start Over?', ['y', 'n'])) === 'y'); |
|
| 180 | 180 | |
| 181 | - } |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - private function _countSubdomains ($subdomains) { |
|
| 183 | + private function _countSubdomains ($subdomains) { |
|
| 184 | 184 | |
| 185 | - if (!is_array($subdomains)) { |
|
| 186 | - return false; |
|
| 187 | - } |
|
| 185 | + if (!is_array($subdomains)) { |
|
| 186 | + return false; |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - return count($subdomains); |
|
| 189 | + return count($subdomains); |
|
| 190 | 190 | |
| 191 | - } |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | 193 | } |
| 194 | 194 | \ No newline at end of file |