| Conditions | 21 |
| Paths | 21 |
| Total Lines | 109 |
| Code Lines | 83 |
| 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 |
||
| 36 | public function getLinkedResource($link) |
||
| 37 | { |
||
| 38 | // Remove https://cloud.acquia.com/api from the path as this is already added by the Connector. |
||
| 39 | $path = str_replace('https://cloud.acquia.com/api', '', $link['path']); |
||
| 40 | |||
| 41 | switch ($link['type']) { |
||
| 42 | case 'alerts': |
||
| 43 | return new \AcquiaCloudApi\Response\InsightAlertsResponse( |
||
| 44 | $this->client->request('get', $path) |
||
|
|
|||
| 45 | ); |
||
| 46 | break; |
||
| 47 | case 'applications': |
||
| 48 | return new \AcquiaCloudApi\Response\ApplicationsResponse( |
||
| 49 | $this->client->request('get', $path) |
||
| 50 | ); |
||
| 51 | break; |
||
| 52 | case 'backups': |
||
| 53 | return new \AcquiaCloudApi\Response\BackupsResponse( |
||
| 54 | $this->client->request('get', $path) |
||
| 55 | ); |
||
| 56 | break; |
||
| 57 | case 'code': |
||
| 58 | return new \AcquiaCloudApi\Response\BranchesResponse( |
||
| 59 | $this->client->request('get', $path) |
||
| 60 | ); |
||
| 61 | break; |
||
| 62 | case 'crons': |
||
| 63 | return new \AcquiaCloudApi\Response\CronsResponse( |
||
| 64 | $this->client->request('get', $path) |
||
| 65 | ); |
||
| 66 | break; |
||
| 67 | case 'databases': |
||
| 68 | return new \AcquiaCloudApi\Response\DatabasesResponse( |
||
| 69 | $this->client->request('get', $path) |
||
| 70 | ); |
||
| 71 | break; |
||
| 72 | case 'domains': |
||
| 73 | return new \AcquiaCloudApi\Response\DomainsResponse( |
||
| 74 | $this->client->request('get', $path) |
||
| 75 | ); |
||
| 76 | break; |
||
| 77 | case 'environments': |
||
| 78 | return new \AcquiaCloudApi\Response\EnvironmentsResponse( |
||
| 79 | $this->client->request('get', $path) |
||
| 80 | ); |
||
| 81 | break; |
||
| 82 | case 'ides': |
||
| 83 | return new \AcquiaCloudApi\Response\IdesResponse( |
||
| 84 | $this->client->request('get', $path) |
||
| 85 | ); |
||
| 86 | break; |
||
| 87 | case 'insight': |
||
| 88 | return new \AcquiaCloudApi\Response\InsightsResponse( |
||
| 89 | $this->client->request('get', $path) |
||
| 90 | ); |
||
| 91 | break; |
||
| 92 | case 'logs': |
||
| 93 | return new \AcquiaCloudApi\Response\LogsResponse( |
||
| 94 | $this->client->request('get', $path) |
||
| 95 | ); |
||
| 96 | break; |
||
| 97 | case 'members': |
||
| 98 | return new \AcquiaCloudApi\Response\MembersResponse( |
||
| 99 | $this->client->request('get', $path) |
||
| 100 | ); |
||
| 101 | break; |
||
| 102 | case 'metrics': |
||
| 103 | return new \AcquiaCloudApi\Response\MetricsResponse( |
||
| 104 | $this->client->request('get', $path) |
||
| 105 | ); |
||
| 106 | break; |
||
| 107 | case 'modules': |
||
| 108 | return new \AcquiaCloudApi\Response\InsightModulesResponse( |
||
| 109 | $this->client->request('get', $path) |
||
| 110 | ); |
||
| 111 | break; |
||
| 112 | case 'notification': |
||
| 113 | return new \AcquiaCloudApi\Response\NotificationResponse( |
||
| 114 | $this->client->request('get', $path) |
||
| 115 | ); |
||
| 116 | break; |
||
| 117 | case 'permissions': |
||
| 118 | return new \AcquiaCloudApi\Response\PermissionsResponse( |
||
| 119 | $this->client->request('get', $path) |
||
| 120 | ); |
||
| 121 | break; |
||
| 122 | case 'servers': |
||
| 123 | return new \AcquiaCloudApi\Response\ServersResponse( |
||
| 124 | $this->client->request('get', $path) |
||
| 125 | ); |
||
| 126 | break; |
||
| 127 | case 'ssl': |
||
| 128 | return new \AcquiaCloudApi\Response\SslCertificatesResponse( |
||
| 129 | $this->client->request('get', $path) |
||
| 130 | ); |
||
| 131 | break; |
||
| 132 | case 'teams': |
||
| 133 | return new \AcquiaCloudApi\Response\TeamsResponse( |
||
| 134 | $this->client->request('get', $path) |
||
| 135 | ); |
||
| 136 | break; |
||
| 137 | case 'variables': |
||
| 138 | return new \AcquiaCloudApi\Response\VariablesResponse( |
||
| 139 | $this->client->request('get', $path) |
||
| 140 | ); |
||
| 141 | break; |
||
| 142 | } |
||
| 143 | |||
| 144 | throw new LinkedResourceNotImplementedException($link['type'] . ' link not implemented in this SDK. Please file an issue here: https://github.com/typhonius/acquia-php-sdk-v2/issues'); |
||
| 145 | } |
||
| 147 |