build() public method

Builds the parameters for an existing function.
public build ( string $functionName )
$functionName string The function name.
Ejemplo n.º 1
0
 /**
  * Defines the mock function.
  *
  * @SuppressWarnings(PHPMD)
  */
 public function defineFunction()
 {
     $name = $this->mock->getName();
     $parameterBuilder = new ParameterBuilder();
     $parameterBuilder->build($name);
     $data = ["namespace" => $this->mock->getNamespace(), "name" => $name, "fqfn" => $this->mock->getFQFN(), "signatureParameters" => $parameterBuilder->getSignatureParameters(), "bodyParameters" => $parameterBuilder->getBodyParameters()];
     $this->template->setVar($data, false);
     $definition = $this->template->render();
     eval($definition);
 }
 /**
  * Builds a MockDelegateFunction for a function.
  *
  * @param string|null $functionName The mocked function.
  *
  * @SuppressWarnings(PHPMD)
  */
 public function build($functionName = null)
 {
     $parameterBuilder = new ParameterBuilder();
     $parameterBuilder->build($functionName);
     $signatureParameters = $parameterBuilder->getSignatureParameters();
     /**
      * If a class with the same signature exists, it is considered equivalent
      * to the generated class.
      */
     $hash = md5($signatureParameters);
     $this->namespace = __NAMESPACE__ . $hash;
     if (class_exists($this->getFullyQualifiedClassName())) {
         return;
     }
     $data = ["namespace" => $this->namespace, "signatureParameters" => $signatureParameters];
     $this->template->setVar($data, false);
     $definition = $this->template->render();
     eval($definition);
 }