/** * Make entity return pre-defined value * * @param mixed $value * @return PStub_Stubber */ public function returnValue($value) { $index = PStub_Stubber_Container::addValue($value); $this->usedIndexes['value'][] = $index; $code = str_replace('%index%', $index, self::$templates['value']); $this->stub($code); return $this; }
/** * Stub chain of methods * * @param string $code */ protected function stub($code) { $this->checkEntity(); if (!$code instanceof Closure) { throw new PStub_Stubber_Exception('Invalid use of chain stubber'); } $callback = $code; $chain = $this->createChain($callback); $index = PStub_Stubber_Container::addValue($chain); $this->usedIndexes['value'][] = $index; $stubCode = str_replace('%index%', $index, self::$templates['value']); $method = $this->getReflectionMethodObject(); $method->setBody($stubCode); }