Class Pel

Description

Class with miscellaneous static methods.

This class will contain various methods that govern the overall behavior of PEL.

Debugging output from PEL can be turned on and off by assigning true or false to Pel::$debug.

Located in /Pel.php (line 85)


	
			
Method Summary
 static void clearExceptions ()
 static void debug (string $format, mixed $args,...)
 static string fmt (string $format, mixed $args,...)
 static array getExceptions ()
 static void maybeThrow (PelException $e)
 static string tra (string $str)
 static void warning (string $format, mixed $args,...)
 boolean getDebug ()
 boolean getStrictParsing ()
 void setDebug (boolean $flag)
 void setStrictParsing (boolean $flag)
Methods
static clearExceptions (line 166)

Clear list of stored exceptions.

Use this function before a call to some method if you intend to check for exceptions afterwards.

void clearExceptions ()
static debug (line 259)

Conditionally output debug information.

This method works just like printf() except that it always terminates the output with a newline, and that it only outputs something if the Pel::$debug is true.

void debug (string $format, mixed $args,...)
  • string $format: the format string.
  • mixed $args,...: any number of arguments can be given. The arguments will be available for the format string as usual with sprintf().
static fmt (line 329)

Translate and format a string.

This static function will first use Gettext to translate a format string, which will then have access to any extra arguments. By always using this function for dynamic string one is assured that the translation will be taken from the correct text domain. If the string is static, use tra instead as it will be faster.

  • return: the translated string, or the original string if no translation could be found.
string fmt (string $format, mixed $args,...)
  • string $format: the format string. This will be translated before being used as a format string.
  • mixed $args,...: any number of arguments can be given. The arguments will be available for the format string as usual with sprintf().
static getExceptions (line 155)

Return list of stored exceptions.

When PEL is parsing in non-strict mode, it will store most exceptions instead of throwing them. Use this method to get hold of them when a call returns.

Code for using this could look like this:

  1.  
  2.  $jpeg new PelJpeg($file);
  3.  
  4.  // Check for exceptions.
  5.   foreach (Pel::getExceptions(as $e{
  6.      printf("Exception: %s\n"$e->getMessage());
  7.      if ($e instanceof PelEntryException{
  8.        // Warn about entries that couldn't be loaded.
  9.               printf("Warning: Problem with %s.\n",
  10.               PelTag::getName($e->getType()$e->getTag()));
  11.      }
  12.  }

This gives applications total control over the amount of error messages shown and (hopefully) provides the necessary information for proper error recovery.

  • return: the exceptions.
array getExceptions ()
static maybeThrow (line 182)

Conditionally throw an exception.

This method will throw the passed exception when strict parsing in effect (see setStrictParsing()). Otherwise the exception is stored (it can be accessed with getExceptions()) and a warning is issued (with Pel::warning).

void maybeThrow (PelException $e)
static tra (line 304)

Translate a string.

This static function will use Gettext to translate a string. By always using this function for static string one is assured that the translation will be taken from the correct text domain. Dynamic strings should be passed to fmt instead.

  • return: the translated string, or the original string if no translation could be found.
string tra (string $str)
  • string $str: the string that should be translated.
static warning (line 282)

Conditionally output a warning.

This method works just like printf() except that it prepends the output with the string 'Warning: ', terminates the output with a newline, and that it only outputs something if the PEL_DEBUG defined to some true value.

void warning (string $format, mixed $args,...)
  • string $format: the format string.
  • mixed $args,...: any number of arguments can be given. The arguments will be available for the format string as usual with sprintf().
getDebug (line 241)

Get current setting for debug output.

  • return: true if debug is enabled, false otherwise.
boolean getDebug ()
getStrictParsing (line 220)

Get current setting for strict parsing.

  • return: true if strict parsing is in effect, false otherwise.
boolean getStrictParsing ()
setDebug (line 231)

Enable/disable debugging output.

void setDebug (boolean $flag)
  • boolean $flag: use true to enable debug output, false to diable.
setStrictParsing (line 209)

Enable/disable strict parsing.

If strict parsing is enabled, then most errors while loading images will result in exceptions being thrown. Otherwise a warning will be emitted (using Pel::warning) and the exceptions will be stored for later use via getExceptions().

Some errors will still be fatal and result in thrown exceptions, but an effort will be made to skip over as much garbage as possible.

void setStrictParsing (boolean $flag)
  • boolean $flag: use true to enable strict parsing, false to diable.

Documentation generated on Tue, 19 Dec 2006 01:08:12 +0100 by phpDocumentor 1.3.0 SourceForge.net Logo