original_string: private function loadFromLocation($location)
      {
          Logger::get()->debug('Loading settings...');
          // Add the trailing slash to the folder if it is missing.
          if (substr($location, -1) != DIRECTORY_SEPARATOR) {
              $location .= DIRECTORY_SEPARATOR;
          }
          $settingsLocation = $location . 'settings.json';
  
          if (!is_readable($settingsLocation)) {
              Logger::get()->error(
                  'Settings file %s cannot be read.',
                  $settingsLocation
              );
              throw new Settings\Exception("Settings file $settingsLocation is unavailable.");
          }
  
          // Load the settings.
          $settings = json_decode(file_get_contents($settingsLocation), true);
          if (empty($settings)) {
              throw new Settings\Exception('Settings file cannot be parsed.');
          }
  
          // Load settings customised for the current environment.
          $environmentSettings = null;
          $environment = self::getEnvironment();
          if ($environment) {
              $environmentSettingsLocation = sprintf(
                  '%ssettings-%s.json',
                  $location,
                  strtolower($environment)
              );
  
              if (is_readable($environmentSettingsLocation)) {
                  $environmentSettings = json_decode(file_get_contents($environmentSettingsLocation), true);
                  if (!empty($environmentSettings)) {
                      $settings = self::mergeSettings($settings, $environmentSettings);
                  }
              }
          }
  
          $this->settings = self::objectify($settings);
  
      }
code: private function loadFromLocation($location)
      {
          Logger::get()->debug('Loading settings...');
          // Add the trailing slash to the folder if it is missing.
          if (substr($location, -1) != DIRECTORY_SEPARATOR) {
              $location .= DIRECTORY_SEPARATOR;
          }
          $settingsLocation = $location . 'settings.json';
  
          if (!is_readable($settingsLocation)) {
              Logger::get()->error(
                  'Settings file %s cannot be read.',
                  $settingsLocation
              );
              throw new Settings\Exception("Settings file $settingsLocation is unavailable.");
          }
  
          // Load the settings.
          $settings = json_decode(file_get_contents($settingsLocation), true);
          if (empty($settings)) {
              throw new Settings\Exception('Settings file cannot be parsed.');
          }
  
          // Load settings customised for the current environment.
          $environmentSettings = null;
          $environment = self::getEnvironment();
          if ($environment) {
              $environmentSettingsLocation = sprintf(
                  '%ssettings-%s.json',
                  $location,
                  strtolower($environment)
              );
  
              if (is_readable($environmentSettingsLocation)) {
                  $environmentSettings = json_decode(file_get_contents($environmentSettingsLocation), true);
                  if (!empty($environmentSettings)) {
                      $settings = self::mergeSettings($settings, $environmentSettings);
                  }
              }
          }
  
          $this->settings = self::objectify($settings);
  
      }
code_tokens: private function loadFromLocation ( $ location ) { Logger :: get ( ) -> debug ( 'Loading settings...' ) ; // Add the trailing slash to the folder if it is missing. if ( substr ( $ location , - 1 ) != DIRECTORY_SEPARATOR ) { $ location .= DIRECTORY_SEPARATOR ; } $ settingsLocation = $ location . 'settings.json' ; if ( ! is_readable ( $ settingsLocation ) ) { Logger :: get ( ) -> error ( 'Settings file %s cannot be read.' , $ settingsLocation ) ; throw new Settings \ Exception ( "Settings file $settingsLocation is unavailable." ) ; } // Load the settings. $ settings = json_decode ( file_get_contents ( $ settingsLocation ) , true ) ; if ( empty ( $ settings ) ) { throw new Settings \ Exception ( 'Settings file cannot be parsed.' ) ; } // Load settings customised for the current environment. $ environmentSettings = null ; $ environment = self :: getEnvironment ( ) ; if ( $ environment ) { $ environmentSettingsLocation = sprintf ( '%ssettings-%s.json' , $ location , strtolower ( $ environment ) ) ; if ( is_readable ( $ environmentSettingsLocation ) ) { $ environmentSettings = json_decode ( file_get_contents ( $ environmentSettingsLocation ) , true ) ; if ( ! empty ( $ environmentSettings ) ) { $ settings = self :: mergeSettings ( $ settings , $ environmentSettings ) ; } } } $ this -> settings = self :: objectify ( $ settings ) ; }
docstring: Load settings from a file.
  
  @param string $location The location of the settings file.
  @throws Settings\Exception
docstring_tokens: Load settings from a file .