<?php
class gtMethod extends gtTestSubject {
private $className;
private $methodName;
private $constructorArgumentNames;
private $constructorArgumentList = '';
private $constructorInitialisationStatements;
public function __construct($className, $methodName) {
$this->className = $className;
$this->methodName = $methodName;
}
public function setConstructorArgumentNames() {
$reflectionClass = new ReflectionClass($this->className);
$constructor = $reflectionClass->getConstructor();
foreach($constructor->getParameters() as $i => $param) {
$this->constructorArgumentNames[] = $param->getName();
}
}
public function setArgumentNames() {
$methodClass = new reflectionMethod($this->className, $this->methodName);
$parameters = $methodClass->getParameters();
foreach ($methodClass->getParameters() as $i => $param) {
if($param->isOptional()) {
$this->optionalArgumentNames[] = $param->getName();
} else {
$this->mandatoryArgumentNames[] = $param->getName();
}
}
}
public function getConstructorArgumentNames() {
return $this->constructorArgumentNames;
}
public function getName() {
return $this->methodName;
}
public function getClassName() {
return $this->className;
}
public function setConstructorArgumentList() {
if(count ($this->constructorArgumentNames) > 0) {
for( $i = 0; $i < count( $this->constructorArgumentNames ); $i++) {
$this->constructorArgumentList .= "\$".$this->constructorArgumentNames[$i].", ";
}
$this->constructorArgumentList = substr($this->constructorArgumentList, 0, -2);
}
}
public function getConstructorArgumentList() {
return $this->constructorArgumentList;
}
public function setConstructorInitStatements() {
if(count ($this->constructorArgumentNames) > 0) {
foreach( $this->constructorArgumentNames as $name) {
$this->constructorInitialisationStatements[] = "\$".$name." = ";
}
}
}
public function getConstructorInitStatements() {
return $this->constructorInitialisationStatements;
}
}
?>