public function config()
 {
     $config = dirname(__FILE__) . '/user.properties';
     if (file_exists($config)) {
         $config = PurProperties::stringToArray(PurFile::read($config));
     } else {
         echo 'First running the test?' . PHP_EOL;
         echo 'A new file user.properties was created in tests directory.' . PHP_EOL;
         echo 'Modify it to feet your HBase installation, then the tests again.' . PHP_EOL;
         exit;
     }
     return $config;
 }
Exemplo n.º 2
0
	/**
	 * Read the content of a file and deserialize it as an array. Unless provided, 
	 * deserialization format is derived from the file path extension.
	 * 
	 * Options include:
	 * - format Deserialization method (js and json accepted);
	 * - from_encoding Encoding of the file being read
	 * - to_encoding Encoding of the returned array
	 * 
	 * @return boolean True on success
	 * @param object $path
	 * @param object $options[optional]
	 */
	public static function read($path,array $options=array()){
		if(!isset($options['format'])){
			$dot = strrpos(basename($path),'.');
			if($dot===false) throw new Exception('Format Undertermined From Path: "'.basename($path).'"');
			$format = substr(basename($path),$dot+1);
		}
		switch($format){
			case 'js':
			case 'json':
				$content = trim(PurFile::read($path));
				try{
					return PurJson::decode($content,$options);
				}catch(Exception $e){
					throw new Exception($e->getMessage().': '.basename($path));
				}
			default:
				throw new Exception('Unsupported Format: "'.$format.'"');
		}
	}
Exemplo n.º 3
0
	/**
	 * Create a multidimentional array from a property formated file.
	 * 
	 * @return array Multidimensional array
	 * @param string $path Path to the property file
	 */
	public static function read($path){
		return PurProperties::stringToArray(PurFile::read($path));
	}