| Conditions | 14 |
| Paths | 24 |
| Total Lines | 42 |
| Code Lines | 34 |
| 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 |
||
| 54 | public function check() { |
||
| 55 | if ($this->checked === true) { |
||
| 56 | return; |
||
| 57 | } |
||
| 58 | $this->checked = true; |
||
| 59 | |||
| 60 | switch (get_class($this->connection->getDatabasePlatform())) { |
||
| 61 | case MySQL80Platform::class: # extends MySQL57Platform |
||
| 62 | case MySQL57Platform::class: # extends MySQLPlatform |
||
| 63 | case MariaDb1027Platform::class: # extends MySQLPlatform |
||
| 64 | case MySqlPlatform::class: |
||
| 65 | $result = $this->connection->prepare('SHOW VARIABLES LIKE "version";'); |
||
| 66 | $result->execute(); |
||
| 67 | $row = $result->fetch(); |
||
| 68 | $version = strtolower($row['Value']); |
||
| 69 | |||
| 70 | if (strpos($version, 'mariadb') !== false) { |
||
| 71 | if (version_compare($version, '10.2', '<')) { |
||
| 72 | $this->description = $this->l10n->t('MariaDB version "%s" is used. Nextcloud 21 will no longer support this version and requires MariaDB 10.2 or higher.', $row['Value']); |
||
| 73 | return; |
||
| 74 | } |
||
| 75 | } else { |
||
| 76 | if (version_compare($version, '8', '<')) { |
||
| 77 | $this->description = $this->l10n->t('MySQL version "%s" is used. Nextcloud 21 will no longer support this version and requires MySQL 8 or higher.', $row['Value']); |
||
| 78 | return; |
||
| 79 | } |
||
| 80 | } |
||
| 81 | break; |
||
| 82 | case SqlitePlatform::class: |
||
| 83 | break; |
||
| 84 | case PostgreSQL100Platform::class: # extends PostgreSQL94Platform |
||
| 85 | case PostgreSQL94Platform::class: |
||
| 86 | $result = $this->connection->prepare('SHOW server_version;'); |
||
| 87 | $result->execute(); |
||
| 88 | $row = $result->fetch(); |
||
| 89 | if (version_compare($row['server_version'], '9.6', '<')) { |
||
| 90 | $this->description = $this->l10n->t('PostgreSQL version "%s" is used. Nextcloud 21 will no longer support this version and requires PostgreSQL 9.6 or higher.', $row['server_version']); |
||
| 91 | return; |
||
| 92 | } |
||
| 93 | break; |
||
| 94 | case OraclePlatform::class: |
||
| 95 | break; |
||
| 96 | } |
||
| 113 |