PHP Classes
elePHPant
Icontem

File: Xyndravandria/Dyverath/ExtendedRepresentingClass.php

Recommend this page to a friend!
  Classes of Mauro Di Girolamo  >  Xyndravandria Dyverath  >  Xyndravandria/Dyverath/ExtendedRepresentingClass.php  >  Download  
File: Xyndravandria/Dyverath/ExtendedRepresentingClass.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Xyndravandria Dyverath
Compose and execute MySQL database queries
Author: By
Last change:
Date: 2 years ago
Size: 7,947 bytes
 

Contents

Class file image Download
<?php
/*
=============================================================================================================================================
| This file is part of a project released under the terms of the Xyndravandria PHP License (XyndravandriaPHPLicense.txt). |
| |
| You should be given a copy of the Xyndravandria PHP License (XyndravandriaPHPLicense.txt) within the same directory as the README.md; |
| if not, you can get a copy at http://Xyndravandria.ohost.de/XyndravandriaPHPLicense.txt . |
| |
| The copyright (c) of this project is owned by Mauro Di Girolamo <maurodigirolamo@.web.de>. |
============================================================================================================================================|



Xyndravandria Dyverath
----------------------
Alpha 0.0.0

Xyndravandria is the name of a collection of projects designed and developed by Mauro Di Girolamo (maurodigirolamo@web.de); he is therefore the copyright (c) owner of Xyndravandria itself and all of its projects.

Xyndravandria Dyverath is released under the terms of the Xyndravandria PHP License (XyndravandriaPHPLicense.txt). You should be given a copy of the Xyndravandria PHP License (XyndravandriaPHPLicense.txt) within the same directory as the README.md; if not, you can get a copy at http://Xyndravandria.ohost.de/XyndravandriaPHPLicense.txt . There might be a release under a freer license for a later, more stable version.

The documentation is either included in ./admin_media/Documentation/ or can be read at http://Xyndravandria.ohost.de/Dyverath/Documentation/.

All projects:

   Xyndravandria Averazain
   http://github.com/MauroDiGirolamo/Xyndravandria_Averazain
   PHP
   Averazain is an Ajax framework supporting also JavaScript disabled clients perfectly - including search engines like Google.
  
   Xyndravandria Dyverath
   http://github.com/MauroDiGirolamo/Xyndravandria_Dyverath
   PHP
   Dyverath is a database access wrapper.
  
   Xyndravandria Erozaver
   http://github.com/MauroDiGirolamo/Xyndravandria_Erozaver
   PHP
   Erozaver is a class extending the type hinting given by the PHP engine (additional support for basic type hinting and size constraints).
  
   Xyndravandria Mondraviel
   http://github.com/MauroDiGirolamo/Xyndravandria_Mondraviel
   PHP
   Mondraviel is a class used to separate HTML from PHP code by firstly register models - files containing place holders embedded in HTML code - and then later fill them dynamically with content by passing values for the place holders.
*/

namespace Xyndravandria\Dyverath;

use
Xyndravandria\Dyverath\Cache;
use
Xyndravandria\Dyverath\Cacheable;
use
Xyndravandria\Dyverath\RepresentingClass;

/// Baseclass of Server, Database and Table.
/// @abstract
abstract class ExtendedRepresentingClass extends RepresentingClass implements Cacheable {
  
  
/// The Cache holding instances of @ref
   /// ExtendedRepresentingClass
   /// "ExtendedRepresentingClasses".
  
private static $Cache;
  
  
/// Whether the Cache of this class is enabled. @n
   /// If the Cache is turned on, any instance of the
   /// class will be inserted into the Cache and if used
   /// again, taken from the Cache instead of instancing
   /// another object.
  
const CacheEnabled = 1;
  
  
/// The @ref ExtendedRepresentingClass
   /// "ExtendedRepresentingClass's" name.
   /// <dl class = "type"><dt><b>%Type:</b></dt>
   /// <dd>string</dd></dl>
   /// @protected
  
protected $Name = null;
  
  
/// Returns ExtendedRepresentingClass::$Name.
   /// @public
   /// @returns string
  
public function Name( ) {
      return
$this->Name;
   }

  
/// Creates a new ExtendedRepresentingClass.
   /// @public
   /// @param string $Name: The @ref
   /// ExtendedRepresentingClass
   /// "ExtendedRepresentingClass's"
   /// name.
  
public function __construct( $Name ) {
     
//\settype( $Name, 'string' );
     
$this->Name = $Name;
      return;
   }

  
/// Returns the default configuration of this
   /// ExtendedRepresentingClass.
   /// @private
   /// @static
   /// @returns integer
   /// @note Overrode
   /// RepresentingClass::DefaultConfiguration( ).
  
public static function DefaultConfiguration( ) {
      return
self::CacheEnabled;
   }

  
/// Instances of @ref ExtendedRepresentingClass
   /// "ExtendedRepresentingClasss" selected by
   /// ExtendedRepresentingClass::Select( ) to be later
   /// used in ExtendedRepresentingClass::__callStatic. @n
   /// <dl class = "type"><dt><b>%Type:</b></dt>
   /// <dd>array of ExtendedRepresentingClass</dd></dl>
   /// @private
   /// @static
  
private static $Instance = array( );

  
/// Returns the instance of an
   /// ExtendedRepresentingClass selected or directly
   /// calls a method of the instance.
   /// @public
   /// @static
   /// @param string $Method: The method to be called.
   /// @param array $Argument: An optional array
   /// containing arguments to be passed to the method.
   /// @returns ExtendedRepresentingClass or mixed
   /// @note Both $Method and $Argument are optional
   /// parameters. @n
   /// Having said that, @n
   /// @verbatim Table::Instance( )->Method( 1, 'String' ) == Table::Instance( 'Method', array( 1, 'String' ) ) @endverbatim
  
public static function Instance( $Method = '', array $Argument = array( ) ) {
     
//\settype( $Method, 'string' );
     
if( ! isset( self::$Instance[ \basename( static::ClassName( ) ) ] ) )
         throw new
XyndravandriaDyverathException( 'Demanded instance of ExtendedRepresentingClass called "' . $ExtendedRepresentingClass . '" has not been selected yet.' );
      else {
        
$Instance = self::$Instance[ \basename( static::ClassName( ) ) ];
         if(
$Method == '' )
            return
$Instance;
         else {
           
$ReflectionMethod = new \ReflectionMethod( $Instance, $Method );
           
$RequiredParameters = $ReflectionMethod->getNumberOfRequiredParameters( );
            if(
$RequiredParameters > 0 && $RequiredParameters != \count( $Argument ) )
               throw new
XyndravandriaDyverathException( 'Argument mismatch: The number of arguments passed to ExtendedRepresentingClass::__callStatic( ) within $Argument[ 1 ] (' . \count( $Argument ) . ') does not match the number of required parameters of to be called method ' . $ExtendedRepresentingClass . '->' . $Method . '( ) (' . $RequiredParameters . ').' );
            else
               return \
call_user_func_array( array( $Instance, $Method ), $Argument );
         }
      }
      return;
   }
  
  
/// Saves the instance of a class to be later used
   /// again by calling
   /// ExtendedRepresentingClass::Instance( ).
   /// @public
   /// @returns ExtendedRepresentingClass
  
public function SaveInstance( ) {
      return
self::$Instance[ \basename( static::ClassName( ) ) ] = $this;
   }
  
  
/// Returns the @ref ExtendedRepresentingClass
   /// "ExtendedRepresentingClass's" unique
   /// identifier.
   /// @public
   /// @returns string
   /// @note Required by the CacheAble interface.
  
public function UniqueIdentifier( ) {
      return
$this->Name;
   }

  
/// Returns this @ref ExtendedRepresentingClass
   /// "ExtendedRepresentingClass's" Cache.
   /// @public
   /// @static
   /// @returns Cache
   /// @note Required by the Cacheable interface.
  
public static function Cache( ) {
      isset(
self::$Cache[ static::ClassName( ) ] ) || self::$Cache[ static::ClassName( ) ] = new Cache( static::ClassName( ) );
      return
self::$Cache[ static::ClassName( ) ];
   }
  
}
?>