| 1 | <?php |
||
| 10 | trait ChecksSSHConnection |
||
| 11 | { |
||
| 12 | use ChecksServer, SSHHostname; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * SSH config file path. |
||
| 16 | * |
||
| 17 | * @return string |
||
| 18 | */ |
||
| 19 | protected function sshConfigFile() |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Get Server name. |
||
| 26 | * |
||
| 27 | * @return null |
||
| 28 | */ |
||
| 29 | protected function getServerName() |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Get server. |
||
| 37 | * @return null |
||
| 38 | */ |
||
| 39 | protected function getServer() |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Check SSH connection. |
||
| 47 | * |
||
| 48 | * @return bool |
||
| 49 | */ |
||
| 50 | protected function checkSSHConnection($server = null, $ssh_config_file = null, $verbose = false) |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Abort if no SSH connection. |
||
| 67 | * |
||
| 68 | * @return bool |
||
| 69 | */ |
||
| 70 | protected function abortIfNoSSHConnection($server = null) |
||
| 78 | } |
||
| 79 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: