home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Resources / Developers / XAMPP 1.5.4 / Windows installer / xampp-win32-1.5.4-installer.exe / xampp / php / pear / CodeGen / Maintainer.php < prev    next >
Encoding:
PHP Script  |  2006-04-07  |  4.6 KB  |  215 lines

  1. <?php
  2. /**
  3.  * A class that describes an extension author or maintainer
  4.  *
  5.  * PHP versions 5
  6.  *
  7.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  8.  * that is available through the world-wide-web at the following URI:
  9.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  10.  * the PHP License and are unable to obtain it through the web, please
  11.  * send a note to license@php.net so we can mail you a copy immediately.
  12.  *
  13.  * @category   Tools and Utilities
  14.  * @package    CodeGen
  15.  * @author     Hartmut Holzgraefe <hartmut@php.net>
  16.  * @copyright  2005 Hartmut Holzgraefe
  17.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  18.  * @version    CVS: $Id: Maintainer.php,v 1.4 2006/02/17 09:47:00 hholzgra Exp $
  19.  * @link       http://pear.php.net/package/CodeGen
  20.  */
  21.  
  22. /**
  23.  * A class that describes an extension author or maintainer
  24.  *
  25.  * This class wraps up the functionality needed for the 
  26.  * command line script. 
  27.  *
  28.  * @category   Tools and Utilities
  29.  * @package    CodeGen
  30.  * @author     Hartmut Holzgraefe <hartmut@php.net>
  31.  * @copyright  2005 Hartmut Holzgraefe
  32.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  33.  * @version    Release: @package_version@
  34.  * @link       http://pear.php.net/package/CodeGen
  35.  */
  36. class CodeGen_Maintainer 
  37. {
  38.     /**
  39.      * Users system account name
  40.      *
  41.      * @var string
  42.      */
  43.     protected $user;
  44.  
  45.     /**
  46.      * Real name
  47.      *
  48.      * @var string
  49.      */
  50.     protected $name;
  51.  
  52.     /**
  53.      * Email address
  54.      *
  55.      * @var string
  56.      */
  57.     protected $email;
  58.  
  59.     /**
  60.      * Role in this project
  61.      *
  62.      * @var string
  63.      */
  64.      protected $role = "developer";
  65.      
  66.     /**
  67.      * First maintainer added?
  68.      *
  69.      * @var bool
  70.      */
  71.      protected static $first = true;
  72.  
  73.     /**
  74.      * Prefix to use in comment headers
  75.      *
  76.      * @var bool
  77.      */
  78.     protected $comment_prefix = "Authors:";
  79.  
  80.     /**
  81.      * Constructor
  82.      *
  83.      * @access public
  84.      * @param  string  CVS user name
  85.      * @param  string  real name
  86.      * @param  string  email address
  87.      * @param  string  role in this project
  88.      */
  89.      function __construct($user="unknown", $name="Anonymous Coward", $email="unknown", $role="unknown")
  90.      {
  91.        $this->user  = $user;
  92.          $this->name  = $name;
  93.          $this->email = $email;
  94.          $this->role  = $role;
  95.  
  96.          if (self::$first) {
  97.              self::$first = false;
  98.          } else {
  99.              $this->comment_prefix = "        ";
  100.          }
  101.      }
  102.  
  103.      /**
  104.       * Set CVS user name
  105.       *
  106.       * @access public
  107.       * @param  string CVS user name
  108.       * @return bool   true on success
  109.       */
  110.      function setUser($name) 
  111.      {
  112.          if (!preg_match('|^[\w-]+$|i', $name)) {
  113.              return PEAR::raiseError("'$name' is not a valid CVS user name");
  114.          }
  115.  
  116.          $this->user = $name;
  117.          return true;
  118.      }
  119.  
  120.      /**
  121.       * CVS user getter
  122.       * 
  123.       * @access public
  124.       * @return string
  125.       */
  126.      function getUser()
  127.      {
  128.          return $this->user;
  129.      }
  130.  
  131.      /**
  132.       * Set real user name
  133.       *
  134.       * @access public
  135.       * @param  string user name
  136.       * @return bool   true on success
  137.       */
  138.      function setName($name) 
  139.      {
  140.          $this->name = $name;
  141.          return true;
  142.      }
  143.  
  144.      /**
  145.       * real name getter
  146.       * 
  147.       * @access public
  148.       * @return string
  149.       */
  150.      function getName()
  151.      {
  152.          return $this->name;
  153.      }
  154.  
  155.  
  156.      /**
  157.       * Set email address
  158.       *
  159.       * @access public
  160.       * @param  string email address
  161.       * @return bool   true on success
  162.       */
  163.      function setEmail($email) 
  164.      {
  165.          // TODO check for valid address
  166.  
  167.          $this->email = $email;
  168.          return true;
  169.      }
  170.  
  171.      /**
  172.       * Set project role
  173.       *
  174.       * @access public
  175.       * @param  string project role
  176.       * @return bool   true on success
  177.       */
  178.      function setRole($role) 
  179.      {
  180.          switch ($role) {
  181.              case "lead": 
  182.              case "developer":
  183.              case "contributor":
  184.              case "helper":
  185.                  $this->role = $role;
  186.                  return true;
  187.            default:
  188.              return PEAR::raiseError("'$role' is not a valid maintainer role");
  189.          }
  190.      }
  191.  
  192.      /**
  193.       * Generate a comment header line for this author
  194.       *
  195.       * @access public
  196.       * @return string comment line 
  197.       */
  198.      function comment()
  199.      {
  200.          $code = sprintf("   | {$this->comment_prefix} %-59s |\n", "{$this->name} <{$this->email}>");
  201.          $prefix = "        ";
  202.  
  203.          return $code;
  204.      }
  205.  
  206. }
  207. /*
  208.  * Local variables:
  209.  * tab-width: 4
  210.  * c-basic-offset: 4
  211.  * indent-tabs-mode:nil
  212.  * End:
  213.  */
  214.  
  215. ?>