PHP Classes
elePHPant
Icontem

File: classes/Extensions.class.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Marius Zadara  >  ExifSort  >  classes/Extensions.class.php  >  Download  
File: classes/Extensions.class.php
Role: Class source
Content type: text/plain
Description: Extensions
Class: ExifSort
Read EXIF information from picture files
Author: By
Last change:
Date: 7 years ago
Size: 1,476 bytes
 

Contents

Class file image Download
<?php

/**
 * Class used to work with the PHP modules.
 * This class cannot be extended anymore.
 *
 * @final
 */
final class Extensions
{
   
/**
     * private member to hold the PHP loaded extensions
     *
     * @var array
     */
   
private $loadedExtensions;
   
   
/**
     * Constructor
     * Used to load the PHP extensions into the private member
     *
     * @return Extensions
     */
   
public function Extensions()
    {
       
// load into the private member the PHP loaded extensions
       
$this->loadedExtensions = get_loaded_extensions();
    }

   
/**
     * This function is used to find out if an extension has been loaded.
     * If not, try to load it at runtime.
     *
     * @param string $extension
     * @return boolean TRUE if the extension has been loaded
     * @return boolean FALSE if the extension is not available/could not be loaded
     * @throws ExifNotFound Exception
     */
   
public function isLoaded($extension)
    {
       
// if the extension has not been loaded,
        // try to load it at runtime
       
if (!extension_loaded($extension) && !@dl($extension))
        {
           
// throw the exception
           
throw new ExifNotFound("The EXIF module could not be loaded !");
           
           
// althought the script will not reach this point in case of exception throwing,
            // for the sake of the return, put the false value
           
return false;
        }
        else
        {
           
// either the module is already loaded or has been loading at runtime,
            // return true
           
return true;
        }
    }
}


?>