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 /src/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 setJPEGQuality (int $quality)
void setStrictParsing (boolean $flag)
Methods
static method clearExceptions (line 201)

Clear list of stored exceptions.

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

static void clearExceptions ()
static method debug (line 294)

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.

static 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 method fmt (line 364)

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.
static 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 method getExceptions (line 190)

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.
static array getExceptions ()
static method maybeThrow (line 217)

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).

static void maybeThrow (PelException $e)
static method tra (line 339)

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.
static string tra (string $str)
  • string $str: the string that should be translated.
static method warning (line 317)

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.

static 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 276)

Get current setting for debug output.

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

Get current setting for JPEG encoding quality.

  • return: the quality.
int getJPEGQuality ()
getStrictParsing (line 255)

Get current setting for strict parsing.

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

Enable/disable debugging output.

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

Set the JPEG encoding quality.

void setJPEGQuality (int $quality)
  • int $quality: an integer between 0 and 100 with 75 being average quality and 95 very good quality.
setStrictParsing (line 244)

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 Thu, 05 May 2011 07:18:55 +0200 by phpDocumentor 1.4.3