public function objectToString($object, $options = array())
	{
		if (is_string($object))
		{
			return $object;
		}

		$format = 'object';
		if (isset($options['format']) && $options['format'])
		{
			$format = $options['format'];
		}

		// Build the object variables string
		$vars = '';
		foreach (get_object_vars($object) as $k => $v)
		{
			if (is_scalar($v))
			{
				switch ($format)
				{
					case 'object':
						$vars .= "\tvar $" . $k . " = '" . addcslashes($v, '\\\'') . "';\n";
					break;
					case 'array':
						$vars .= "\t'" . $k . "' => '" . addcslashes($v, '\\\'') . "',\n";
					break;
				}
			}
			elseif (is_array($v) || is_object($v))
			{
				switch ($format)
				{
					case 'object':
						$vars .= "\tvar $" . $k . " = " . $this->getArrayString((array) $v) . ";\n";
					break;
					case 'array':
						$vars .= "\t'" . $k . "' => " . $this->getArrayString((array) $v) . ",\n";
					break;
				}
			}
			elseif (is_null($v))
			{
				switch ($format)
				{
					case 'object':
						$vars .= "\tvar $" . $k . " = '';\n";
					break;
					case 'array':
						$vars .= "\t'" . $k . "' => '',\n";
					break;
				}
			}
		}

		$str  = "<?php\n";
		switch ($format)
		{
			case 'object':
				if (!isset($options['class']) || !$options['class'])
				{
					$options['class'] = 'Config';
				}
				$str .= "class " . $options['class'] . "\n";
				$str .= "{\n";
				$str .= $vars;
				$str .= "}";
			break;
			case 'array':
				$str .= "return array(\n";
				$str .= $vars;
				$str .= ");";
			break;
		}

		// Use the closing tag if it not set to false in parameters.
		if (isset($options['closingtag']) && $options['closingtag'])
		{
			$str .= "\n?>";
		}

		return $str;
	}
public function objectToString($object, $options = array())
	{
		if (is_string($object))
		{
			return $object;
		}

		$format = 'object';
		if (isset($options['format']) && $options['format'])
		{
			$format = $options['format'];
		}

		// Build the object variables string
		$vars = '';
		foreach (get_object_vars($object) as $k => $v)
		{
			if (is_scalar($v))
			{
				switch ($format)
				{
					case 'object':
						$vars .= "\tvar $" . $k . " = '" . addcslashes($v, '\\\'') . "';\n";
					break;
					case 'array':
						$vars .= "\t'" . $k . "' => '" . addcslashes($v, '\\\'') . "',\n";
					break;
				}
			}
			elseif (is_array($v) || is_object($v))
			{
				switch ($format)
				{
					case 'object':
						$vars .= "\tvar $" . $k . " = " . $this->getArrayString((array) $v) . ";\n";
					break;
					case 'array':
						$vars .= "\t'" . $k . "' => " . $this->getArrayString((array) $v) . ",\n";
					break;
				}
			}
			elseif (is_null($v))
			{
				switch ($format)
				{
					case 'object':
						$vars .= "\tvar $" . $k . " = '';\n";
					break;
					case 'array':
						$vars .= "\t'" . $k . "' => '',\n";
					break;
				}
			}
		}

		$str  = "<?php\n";
		switch ($format)
		{
			case 'object':
				if (!isset($options['class']) || !$options['class'])
				{
					$options['class'] = 'Config';
				}
				$str .= "class " . $options['class'] . "\n";
				$str .= "{\n";
				$str .= $vars;
				$str .= "}";
			break;
			case 'array':
				$str .= "return array(\n";
				$str .= $vars;
				$str .= ");";
			break;
		}

		// Use the closing tag if it not set to false in parameters.
		if (isset($options['closingtag']) && $options['closingtag'])
		{
			$str .= "\n?>";
		}

		return $str;
	}
public function objectToString ( $ object , $ options = array ( ) ) { if ( is_string ( $ object ) ) { return $ object ; } $ format = 'object' ; if ( isset ( $ options [ 'format' ] ) && $ options [ 'format' ] ) { $ format = $ options [ 'format' ] ; } // Build the object variables string $ vars = '' ; foreach ( get_object_vars ( $ object ) as $ k => $ v ) { if ( is_scalar ( $ v ) ) { switch ( $ format ) { case 'object' : $ vars .= "\tvar $" . $ k . " = '" . addcslashes ( $ v , '\\\'' ) . "';\n" ; break ; case 'array' : $ vars .= "\t'" . $ k . "' => '" . addcslashes ( $ v , '\\\'' ) . "',\n" ; break ; } } elseif ( is_array ( $ v ) || is_object ( $ v ) ) { switch ( $ format ) { case 'object' : $ vars .= "\tvar $" . $ k . " = " . $ this -> getArrayString ( ( array ) $ v ) . ";\n" ; break ; case 'array' : $ vars .= "\t'" . $ k . "' => " . $ this -> getArrayString ( ( array ) $ v ) . ",\n" ; break ; } } elseif ( is_null ( $ v ) ) { switch ( $ format ) { case 'object' : $ vars .= "\tvar $" . $ k . " = '';\n" ; break ; case 'array' : $ vars .= "\t'" . $ k . "' => '',\n" ; break ; } } } $ str = "<?php\n" ; switch ( $ format ) { case 'object' : if ( ! isset ( $ options [ 'class' ] ) || ! $ options [ 'class' ] ) { $ options [ 'class' ] = 'Config' ; } $ str .= "class " . $ options [ 'class' ] . "\n" ; $ str .= "{\n" ; $ str .= $ vars ; $ str .= "}" ; break ; case 'array' : $ str .= "return array(\n" ; $ str .= $ vars ; $ str .= ");" ; break ; } // Use the closing tag if it not set to false in parameters. if ( isset ( $ options [ 'closingtag' ] ) && $ options [ 'closingtag' ] ) { $ str .= "\n?>" ; } return $ str ; }
Converts an object into a php class or array string.

@param   object  $object   Data Source Object
@param   array   $options  Parameters used by the formatter
@return  string  Config class formatted string
Converts an object into a php class or array string .