/** * Replace all stubs in method's body * * @param string $body * @return string|boolean - new body, or false, if no replacement was needed */ private function replaceWithStubsIn($body) { $stubsList = $this->stub->getStubsList(); $classes = array_keys($stubsList); $stubs = array_values($stubsList); $needReplacement = false; foreach ($classes as $stubbedClass) { if (strpos($body, $stubbedClass) !== false) { $needReplacement = true; break; } } if (!$needReplacement) { return false; } $newBody = str_replace($classes, $stubs, $body); return $newBody; }
/** * Set default stub suffix to be used in all stubs * * @param string $suffix */ public static function setDefaultStubSuffix($suffix) { self::$defaultStubSuffix = $suffix; }