1 | <?php |
||
11 | class CloudEnvironment extends Environment implements CloudEnvironmentInterface |
||
12 | { |
||
13 | /** |
||
14 | * @var string |
||
15 | */ |
||
16 | private $sitegroup; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | private $filepath; |
||
22 | |||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | private $creds; |
||
27 | |||
28 | /** |
||
29 | * Acquia Cloud variables may be set in settings.inc after PHP init, |
||
30 | * so make sure that we are loading them. |
||
31 | * |
||
32 | * @param string $key |
||
33 | * @return string The value of the environment variable or false if not found |
||
34 | * @see https://github.com/acquia/acquia-sdk-php/pull/58#issuecomment-45167451 |
||
35 | */ |
||
36 | 78 | protected function getenv($key) |
|
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | 78 | public function init() |
|
58 | |||
59 | /** |
||
60 | * {@inheritDoc} |
||
61 | */ |
||
62 | 6 | public function isAcquia() |
|
66 | |||
67 | /** |
||
68 | * @return bool |
||
69 | */ |
||
70 | 6 | public function isProduction() |
|
74 | |||
75 | /** |
||
76 | * @param string $sitegroup |
||
77 | * |
||
78 | * @return \Acquia\Cloud\Environment\CloudEnvironment |
||
79 | */ |
||
80 | 3 | public function setSiteGroup($sitegroup) |
|
85 | |||
86 | /** |
||
87 | * @rturn string |
||
88 | * |
||
89 | * @throws \UnexpectedValueException |
||
90 | */ |
||
91 | 15 | public function getSiteGroup() |
|
101 | |||
102 | /** |
||
103 | * @param string $filepath |
||
104 | * |
||
105 | * @return \Acquia\Cloud\Environment\CloudEnvironment |
||
106 | */ |
||
107 | 21 | public function setCredentialsFilepath($filepath) |
|
112 | |||
113 | /** |
||
114 | * @return string |
||
115 | */ |
||
116 | 21 | public function getCredentialsFilepath() |
|
124 | |||
125 | /** |
||
126 | * @return array |
||
127 | * |
||
128 | * @throws \RuntimeException |
||
129 | */ |
||
130 | 15 | public function serviceCredentials() |
|
138 | } |
||
139 |
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: