PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
media-cloud-sync / includes / sdk / s3 / Aws / Token / ParsesIniTrait.php

ParsesIniTrait.php in Media Cloud Sync 1.4.2, at includes/sdk/s3/Aws/Token/ParsesIniTrait.php

42 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Dudlewebs\WPMCS\s3\Aws\Token;
4
5 trait ParsesIniTrait
6 {
7 /**
8 * Gets profiles from specified $filename, or default ini files.
9 */
10 private static function loadProfiles($filename)
11 {
12 $profileData = \Dudlewebs\WPMCS\s3\Aws\parse_ini_file($filename, \true, \INI_SCANNER_RAW);
13 $configFilename = self::getHomeDir() . '/.aws/config';
14 if (\is_readable($configFilename)) {
15 $configProfiles = \Dudlewebs\WPMCS\s3\Aws\parse_ini_file($configFilename, \true, \INI_SCANNER_RAW);
16 $profileData = \array_merge($configProfiles, $profileData);
17 }
18 foreach ($profileData as $name => $profile) {
19 // standardize config profile names
20 $name = \str_replace('profile ', '', $name);
21 $profileData[$name] = $profile;
22 }
23 return $profileData;
24 }
25 /**
26 * Gets the environment's HOME directory if available.
27 *
28 * @return null|string
29 */
30 private static function getHomeDir()
31 {
32 // On Linux/Unix-like systems, use the HOME environment variable
33 if ($homeDir = \getenv('HOME')) {
34 return $homeDir;
35 }
36 // Get the HOMEDRIVE and HOMEPATH values for Windows hosts
37 $homeDrive = \getenv('HOMEDRIVE');
38 $homePath = \getenv('HOMEPATH');
39 return $homeDrive && $homePath ? $homeDrive . $homePath : null;
40 }
41 }
42