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