Source for file Map.class.php

Documentation is available at Map.class.php

  1. <?php
  2. /**
  3.  * Gumbo Library Framework
  4.  *
  5.  * LICENSE
  6.  * This library is being released under the terms of the New BSD License.  A
  7.  * copy of the license is packaged with the software (LICENSE.txt).  If no
  8.  * copy is found, a copy of the license template can be found at:
  9.  * http://www.opensource.org/licenses/bsd-license.php
  10.  * 
  11.  * @category Gumbo
  12.  * @package Map
  13.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  14.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  15.  * @author Michael Luster <mluster79@yahoo.com>
  16.  * @link http://sourceforge.net/projects/phpgumbo
  17.  * @version 0.0.1
  18.  */
  19.  
  20. /**
  21.  * Map Interface
  22.  * 
  23.  * The Map is responsible for creating a reference from a source (internal)
  24.  * key to a foreign (external) key.  The Source Key is important to the Mapper
  25.  * Class.  The Foreign Key is from some outside source.  Every Source Key must
  26.  * have a Foreign Key reference.
  27.  * 
  28.  * The best example to use would be to map HTML Form Input data to the private
  29.  * properties of a class.  The Source Key would be the name of the private
  30.  * property.  The Foreign Key would be the name of the HTML Form Field.  A Mapper
  31.  * Class will use the generated Map to process the information.  The Map only
  32.  * holds the appropriate key references.
  33.  *
  34.  * @category Gumbo
  35.  * @package Map
  36.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  37.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  38.  * @author Michael Luster <mluster79@yahoo.com>
  39.  * @link http://sourceforge.net/projects/phpgumbo
  40.  * @desc Map Interface
  41.  * @version 0.0.1
  42.  */
  43.  
  44. interface Gumbo_Interface_Map {
  45.     
  46.     /** ACTION METHODS **/
  47.     /**
  48.      * Adds a foreign key reference to a source key
  49.      * @param string $source_key 
  50.      * @param string $foreign_key 
  51.      */
  52.     public function add ($source_key$foreign_key);
  53.     
  54.     /**
  55.      * Removes the foreign key reference to a source key
  56.      * @param string $source_key 
  57.      */
  58.     public function remove ($source_key);
  59.     
  60.     /**
  61.      * Resets all keys
  62.      * @postcondition empty key references
  63.      */
  64.     public function reset ();
  65.     
  66.     
  67.     
  68.     /** ACCESSOR METHODS **/
  69.     /**
  70.      * Returns the source key referenced by the foreign key
  71.      * @precondition isForeignKey ($foreign_key)
  72.      * @param string $foreign_key 
  73.      * @return string 
  74.      */
  75.     public function getKey ($foreign_key);
  76.     
  77.     /**
  78.      * Returns the foreign key reference to the source key
  79.      * @precondition isKey ($source_key)
  80.      * @param string $source_key 
  81.      * @return string 
  82.      */
  83.     public function getForeignKey ($source_key);
  84.     
  85.     /**
  86.      * Returns all the keys as an associative array where key=>source_key, val=>foreign_key
  87.      * @return array 
  88.      */
  89.     public function getAll ();
  90.     
  91.     /**
  92.      * Returns if the source key exists
  93.      * @param string $source_key 
  94.      * @return bool 
  95.      */
  96.     public function isKey ($source_key);
  97.     
  98.     /**
  99.      * Returns if the foreign key exists
  100.      * @param string $foreign_key 
  101.      * @return bool 
  102.      */
  103.     public function isForeignKey ($foreign_key);
  104.     
  105. }
  106.  
  107. ?>