http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72287

Revision: 72287
Author:   jeroendedauw
Date:     2010-09-03 14:51:33 +0000 (Fri, 03 Sep 2010)

Log Message:
-----------
Changes for 0.4 - work on Parameter class

Modified Paths:
--------------
    trunk/extensions/Validator/includes/Parameter.php

Modified: trunk/extensions/Validator/includes/Parameter.php
===================================================================
--- trunk/extensions/Validator/includes/Parameter.php   2010-09-03 14:24:40 UTC 
(rev 72286)
+++ trunk/extensions/Validator/includes/Parameter.php   2010-09-03 14:51:33 UTC 
(rev 72287)
@@ -13,17 +13,65 @@
 class Parameter {
        
        const TYPE_STRING = 'string';
+       const TYPE_NUMBER = 'number';
+       const TYPE_INTEGER = 'integer';
+       const TYPE_BOOLEAN = 'boolean';
+       const TYPE_CHAR = 'char';
        
+       /**
+        * The main name of the parameter.
+        * 
+        * @since 0.4
+        * 
+        * @var string
+        */
        protected $name;
        
+       /**
+        * The type of the parameter. Is either a string of the 
Parameter::TYPE_ enum,
+        * or an array with such a string as first element, and optionaly a 
delimiter
+        * as second element for list types.
+        * 
+        * @since 0.4
+        * 
+        * @var mixed
+        */
        protected $type;
        
+       /**
+        * The default value for the parameter, or null when the parameter is 
required.
+        * 
+        * @since 0.4
+        * 
+        * @var mixed
+        */
        protected $default;
        
+       /**
+        * List of aliases for the parameter name.
+        * 
+        * @since 0.4
+        * 
+        * @var array
+        */     
        protected $aliases;
        
+       /**
+        * List of criteria the parameter value needs to hold against.
+        * 
+        * @since 0.4
+        * 
+        * @var array
+        */             
        protected $criteria;
        
+       /**
+        * List of formatting functions to shape the final form of the 
parameter value. 
+        * 
+        * @since 0.4
+        * 
+        * @var array
+        */                     
        protected $outputTypes;
        
        /**
@@ -104,17 +152,73 @@
         * @since 0.4
         * 
         * @param string $name
-        * @param string $type
+        * @param mixed $type
         * @param mixed $default Use null for no default (which makes the 
parameter required)
         * @param array $aliases
         * @param array $criteria
         */
        public function __construct( $name, $type = Parameter::TYPE_STRING, 
$default = null, array $aliases = array(), array $criteria = array() ) {
-               
+               $this->name = $name;
+               $this->type = $type;
+               $this->default = $default;
+               $this->aliases = $aliases;
+               $this->criteria = $criteria;
        }
        
-       public function setOutputTypes( $outputTypes ) {
+       /**
+        * Sets the output types to the provided value.
+        * 
+        * @since 0.4
+        * 
+        * @param array $outputTypes
+        */
+       public function setOutputTypes( array $outputTypes ) {
                $this->outputTypes = outputTypes;
        }
        
+       /**
+        * Returns the parameters main name.
+        * 
+        * @since 0.4
+        * 
+        * @return string
+        */                     
+       public function getName() {
+               return $this->name;
+       }
+       
+       /**
+        * Returns if the parameter is a required one or not.
+        * 
+        * @since 0.4
+        * 
+        * @return boolean
+        */             
+       public function isRequired() {
+               return is_null( $this->default );
+       }
+       
+       /**
+        * Returns the parameter criteria.
+        * 
+        * @since 0.4
+        * 
+        * @return array
+        */     
+       public function getCriteria() {
+               // TODO: type criteria resolving
+               return $this->criteria; 
+       }
+       
+       /**
+        * Returns the parameter name aliases.
+        * 
+        * @since 0.4
+        * 
+        * @return array
+        */
+       public function getAliases() {
+               return $this->aliases;
+       }
+       
 }
\ No newline at end of file



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to