Exemple #1
0
 /**
  * Load a configuration file
  * @param string $file Path to the configuration file
  * @param \Packfire\Config\ConfigInterface $defaults (optional) The default configuration data to load with.
  * @return \Packfire\Config\ConfigInterface Returns the loaded configuration, or NULL if failed to
  *                 find the appropriate configuration parser.
  * @since 1.0
  */
 public function load($file, ConfigInterface $defaults = null)
 {
     $map = ConfigType::typeMap();
     $ext = pathinfo($file, PATHINFO_EXTENSION);
     if (isset($map[$ext])) {
         $class = 'Packfire\\Config\\Driver\\' . $map[$ext];
         $config = new $class($file);
         $config->read();
         if ($defaults) {
             $config->defaults($defaults);
         }
         return $config;
     } else {
         return null;
     }
 }
Exemple #2
0
 /**
  * @covers \Packfire\Config\ConfigType::typeMap
  */
 public function testTypeMap()
 {
     $this->assertInternalType('array', ConfigType::typeMap());
 }