@@ -124,23 +124,26 @@ discard block |
||
| 124 | 124 | private function parseConfiguration(InputInterface $input) |
| 125 | 125 | { |
| 126 | 126 | // Check that the configuration file exists |
| 127 | - if (!file_exists($input->getArgument('configFile'))) |
|
| 128 | - throw new InvalidConfigurationException('The specified configuration file does not exist'); |
|
| 127 | + if (!file_exists($input->getArgument('configFile'))) { |
|
| 128 | + throw new InvalidConfigurationException('The specified configuration file does not exist'); |
|
| 129 | + } |
|
| 129 | 130 | |
| 130 | 131 | // Check that the database exists and is writable |
| 131 | 132 | $databasePath = $input->getArgument('databaseFile'); |
| 132 | 133 | |
| 133 | - if (!file_exists($databasePath)) |
|
| 134 | - throw new InvalidConfigurationException('The specified database path does not exist'); |
|
| 135 | - else if (!is_writable($databasePath)) |
|
| 136 | - throw new InvalidConfigurationException('The specified database path is not writable'); |
|
| 134 | + if (!file_exists($databasePath)) { |
|
| 135 | + throw new InvalidConfigurationException('The specified database path does not exist'); |
|
| 136 | + } else if (!is_writable($databasePath)) { |
|
| 137 | + throw new InvalidConfigurationException('The specified database path is not writable'); |
|
| 138 | + } |
|
| 137 | 139 | |
| 138 | 140 | // Parse the configuration file |
| 139 | 141 | $configuration = parse_ini_file($input->getArgument('configFile'), true); |
| 140 | 142 | |
| 141 | 143 | // Check that the file was parsed |
| 142 | - if ($configuration === false) |
|
| 143 | - throw new InvalidConfigurationException('Failed to parse the specified configuration file'); |
|
| 144 | + if ($configuration === false) { |
|
| 145 | + throw new InvalidConfigurationException('Failed to parse the specified configuration file'); |
|
| 146 | + } |
|
| 144 | 147 | |
| 145 | 148 | $instances = []; |
| 146 | 149 | |
@@ -157,12 +160,14 @@ discard block |
||
| 157 | 160 | $instance = new Instance($name, $address, $port); |
| 158 | 161 | |
| 159 | 162 | // Optionally set ignored users |
| 160 | - if (isset($values['ignoredUsers'])) |
|
| 161 | - $instance->setIgnoredUsers($values['ignoredUsers']); |
|
| 163 | + if (isset($values['ignoredUsers'])) { |
|
| 164 | + $instance->setIgnoredUsers($values['ignoredUsers']); |
|
| 165 | + } |
|
| 162 | 166 | |
| 163 | 167 | // Optionally set credentials |
| 164 | - if (isset($values['username']) && isset($values['password'])) |
|
| 165 | - $instance->setCredentials($values['username'], $values['password']); |
|
| 168 | + if (isset($values['username']) && isset($values['password'])) { |
|
| 169 | + $instance->setCredentials($values['username'], $values['password']); |
|
| 170 | + } |
|
| 166 | 171 | |
| 167 | 172 | $instances[] = $instance; |
| 168 | 173 | break; |
@@ -170,8 +175,9 @@ discard block |
||
| 170 | 175 | } |
| 171 | 176 | |
| 172 | 177 | // Validate the configuration. We need at least one instance. |
| 173 | - if (empty($instances)) |
|
| 174 | - throw new InvalidConfigurationException('No instances defined, you need to specify at least one instance'); |
|
| 178 | + if (empty($instances)) { |
|
| 179 | + throw new InvalidConfigurationException('No instances defined, you need to specify at least one instance'); |
|
| 180 | + } |
|
| 175 | 181 | |
| 176 | 182 | // Create the configuration object |
| 177 | 183 | $config = new Configuration($databasePath, $instances); |
@@ -200,8 +206,9 @@ discard block |
||
| 200 | 206 | */ |
| 201 | 207 | private static function getSectionType($section) |
| 202 | 208 | { |
| 203 | - if (substr($section, 0, 8) === 'instance') |
|
| 204 | - return Configuration::SECTION_TYPE_INSTANCE; |
|
| 209 | + if (substr($section, 0, 8) === 'instance') { |
|
| 210 | + return Configuration::SECTION_TYPE_INSTANCE; |
|
| 211 | + } |
|
| 205 | 212 | |
| 206 | 213 | throw new InvalidConfigurationException('Unknown section "' . $section . '"'); |
| 207 | 214 | } |