Back to index

php5  5.3.10
gtMethod.php
Go to the documentation of this file.
00001 <?php
00002 
00006 class gtMethod  extends gtTestSubject {
00007 
00008   private $className;
00009   private $methodName;
00010   private $constructorArgumentNames;
00011   private $constructorArgumentList = '';
00012   private $constructorInitialisationStatements;
00013 
00014 
00015 
00022   public function __construct($className, $methodName) {
00023     $this->className = $className;
00024     $this->methodName = $methodName;
00025   }
00026 
00027 
00032   public function setConstructorArgumentNames() {
00033     $reflectionClass = new ReflectionClass($this->className);
00034     $constructor = $reflectionClass->getConstructor();
00035     foreach($constructor->getParameters() as $i => $param) {
00036       //if(!$param->isOptional()) {
00037         $this->constructorArgumentNames[] = $param->getName();
00038       //}
00039     }
00040   }
00041 
00042   
00047   public function setArgumentNames() {
00048 
00049     $methodClass  = new reflectionMethod($this->className, $this->methodName);
00050     $parameters = $methodClass->getParameters();
00051 
00052     foreach ($methodClass->getParameters() as $i => $param) {
00053       if($param->isOptional()) {
00054         $this->optionalArgumentNames[] = $param->getName();
00055       } else {
00056         $this->mandatoryArgumentNames[] = $param->getName();
00057       }
00058 
00059     }
00060   }
00061 
00062 
00068   public function getConstructorArgumentNames() {
00069     return $this->constructorArgumentNames;
00070   }
00071 
00077   public function getName() {
00078     return $this->methodName;
00079   }
00080 
00081 
00087   public function getClassName() {
00088     return $this->className;
00089   }
00090   
00095   public function setConstructorArgumentList() {
00096     if(count ($this->constructorArgumentNames) > 0) {
00097       
00098       for( $i = 0; $i < count( $this->constructorArgumentNames ); $i++) {
00099         $this->constructorArgumentList .= "\$".$this->constructorArgumentNames[$i].", ";
00100       }
00101       $this->constructorArgumentList = substr($this->constructorArgumentList, 0, -2);
00102     }
00103   }
00104 
00105 
00111   public function getConstructorArgumentList() {
00112     return $this->constructorArgumentList;
00113   }
00114 
00115   
00120   public function setConstructorInitStatements() {
00121     if(count ($this->constructorArgumentNames) > 0) {
00122       foreach( $this->constructorArgumentNames as $name) {
00123         $this->constructorInitialisationStatements[] = "\$".$name." = ";
00124       }
00125     }
00126 
00127   }
00128 
00129   
00135   public function getConstructorInitStatements() {
00136     return $this->constructorInitialisationStatements;
00137   }
00138 }
00139 ?>