src/Mock/MockGenerator.php
public function generate(
        MockDefinition $definition,
        string $className = ''
    ): string {
        if ('' === $className) {
            $className = $this->generateClassName($definition);
        }

        $source = $this->generateHeader($definition, $className) .
            $this->generateConstants($definition) .
            $this->generateMethods(
                $definition->methods()->publicStaticMethods()
            ) .
            $this->generateMagicCallStatic($definition) .
            $this->generateStructors($definition) .
            $this->generateMethods($definition->methods()->publicMethods()) .
            $this->generateMagicCall($definition) .
            $this->generateMethods(
                $definition->methods()->protectedStaticMethods()
            ) .
            $this->generateMethods($definition->methods()->protectedMethods()) .
            $this->generateCallParentMethods($definition) .
            $this->generateProperties($definition) .
            "\n}\n";

        // @codeCoverageIgnoreStart
        if (PHP_EOL !== "\n") {
            $source = str_replace("\n", PHP_EOL, $source);
        }
        // @codeCoverageIgnoreEnd

        return $source;
    }
public function generate(
        MockDefinition $definition,
        string $className = ''
    ): string {
        if ('' === $className) {
            $className = $this->generateClassName($definition);
        }

        $source = $this->generateHeader($definition, $className) .
            $this->generateConstants($definition) .
            $this->generateMethods(
                $definition->methods()->publicStaticMethods()
            ) .
            $this->generateMagicCallStatic($definition) .
            $this->generateStructors($definition) .
            $this->generateMethods($definition->methods()->publicMethods()) .
            $this->generateMagicCall($definition) .
            $this->generateMethods(
                $definition->methods()->protectedStaticMethods()
            ) .
            $this->generateMethods($definition->methods()->protectedMethods()) .
            $this->generateCallParentMethods($definition) .
            $this->generateProperties($definition) .
            "\n}\n";

        // @codeCoverageIgnoreStart
        if (PHP_EOL !== "\n") {
            $source = str_replace("\n", PHP_EOL, $source);
        }
        // @codeCoverageIgnoreEnd

        return $source;
    }
public function generate ( MockDefinition $ definition , string $ className = '' ) : string { if ( '' === $ className ) { $ className = $ this -> generateClassName ( $ definition ) ; } $ source = $ this -> generateHeader ( $ definition , $ className ) . $ this -> generateConstants ( $ definition ) . $ this -> generateMethods ( $ definition -> methods ( ) -> publicStaticMethods ( ) ) . $ this -> generateMagicCallStatic ( $ definition ) . $ this -> generateStructors ( $ definition ) . $ this -> generateMethods ( $ definition -> methods ( ) -> publicMethods ( ) ) . $ this -> generateMagicCall ( $ definition ) . $ this -> generateMethods ( $ definition -> methods ( ) -> protectedStaticMethods ( ) ) . $ this -> generateMethods ( $ definition -> methods ( ) -> protectedMethods ( ) ) . $ this -> generateCallParentMethods ( $ definition ) . $ this -> generateProperties ( $ definition ) . "\n}\n" ; // @codeCoverageIgnoreStart if ( PHP_EOL !== "\n" ) { $ source = str_replace ( "\n" , PHP_EOL , $ source ) ; } // @codeCoverageIgnoreEnd return $ source ; }
Generate a mock class and return the source code.

@param MockDefinition $definition The definition.
@param string         $className  The class name.

@return string The source code.
Generate a mock class and return the source code .