src/Plugin/Double.php
public static function generate($options = [])
    {
        $defaults = [
            'class'      => 'Kahlan\Spec\Plugin\Double\Double' . static::$_index++,
            'extends'    => '',
            'implements' => [],
            'uses'       => [],
            'methods'    => [],
            'layer'      => null,
            'openTag'    => true,
            'closeTag'   => true
        ];
        $options += $defaults;

        if ($options['extends'] || $options['implements']) {
            $options += ['magicMethods' => false];
        } else {
            $options += ['magicMethods' => true];
        }

        $class = $options['class'];
        $namespace = '';
        if (($pos = strrpos($class, '\\')) !== false) {
            $namespace = substr($class, 0, $pos);
            $class = substr($class, $pos + 1);
        }

        if ($namespace) {
            $namespace = "namespace {$namespace};\n";
        }

        $uses = static::_generateUses($options['uses']);
        $extends = static::_generateExtends($options['extends']);
        $implements = static::_generateImplements($options['implements']);

        $methods = static::_generateMethodStubs($options['methods'], $options['magicMethods']);
        if ($options['extends']) {
            $methods += static::_generateClassMethods($options['extends'], $options['layer']);
        }
        $methods += static::_generateInterfaceMethods($options['implements']);

        $methods = $methods ? '    ' . join("\n    ", $methods) : '';

        $openTag = $options['openTag'] ? "<?php\n" : '';
        $closeTag = $options['closeTag'] ? "?>" : '';

        return $openTag . $namespace . <<<EOT

class {$class}{$extends}{$implements} {

{$uses}{$methods}

}
$closeTag
EOT;
    }
public static function generate($options = [])
    {
        $defaults = [
            'class'      => 'Kahlan\Spec\Plugin\Double\Double' . static::$_index++,
            'extends'    => '',
            'implements' => [],
            'uses'       => [],
            'methods'    => [],
            'layer'      => null,
            'openTag'    => true,
            'closeTag'   => true
        ];
        $options += $defaults;

        if ($options['extends'] || $options['implements']) {
            $options += ['magicMethods' => false];
        } else {
            $options += ['magicMethods' => true];
        }

        $class = $options['class'];
        $namespace = '';
        if (($pos = strrpos($class, '\\')) !== false) {
            $namespace = substr($class, 0, $pos);
            $class = substr($class, $pos + 1);
        }

        if ($namespace) {
            $namespace = "namespace {$namespace};\n";
        }

        $uses = static::_generateUses($options['uses']);
        $extends = static::_generateExtends($options['extends']);
        $implements = static::_generateImplements($options['implements']);

        $methods = static::_generateMethodStubs($options['methods'], $options['magicMethods']);
        if ($options['extends']) {
            $methods += static::_generateClassMethods($options['extends'], $options['layer']);
        }
        $methods += static::_generateInterfaceMethods($options['implements']);

        $methods = $methods ? '    ' . join("\n    ", $methods) : '';

        $openTag = $options['openTag'] ? "<?php\n" : '';
        $closeTag = $options['closeTag'] ? "?>" : '';

        return $openTag . $namespace . <<<EOT

class {$class}{$extends}{$implements} {

{$uses}{$methods}

}
$closeTag
EOT;
    }
public static function generate ( $ options = [ ] ) { $ defaults = [ 'class' => 'Kahlan\Spec\Plugin\Double\Double' . static :: $ _index ++ , 'extends' => '' , 'implements' => [ ] , 'uses' => [ ] , 'methods' => [ ] , 'layer' => null , 'openTag' => true , 'closeTag' => true ] ; $ options += $ defaults ; if ( $ options [ 'extends' ] || $ options [ 'implements' ] ) { $ options += [ 'magicMethods' => false ] ; } else { $ options += [ 'magicMethods' => true ] ; } $ class = $ options [ 'class' ] ; $ namespace = '' ; if ( ( $ pos = strrpos ( $ class , '\\' ) ) !== false ) { $ namespace = substr ( $ class , 0 , $ pos ) ; $ class = substr ( $ class , $ pos + 1 ) ; } if ( $ namespace ) { $ namespace = "namespace {$namespace};\n" ; } $ uses = static :: _generateUses ( $ options [ 'uses' ] ) ; $ extends = static :: _generateExtends ( $ options [ 'extends' ] ) ; $ implements = static :: _generateImplements ( $ options [ 'implements' ] ) ; $ methods = static :: _generateMethodStubs ( $ options [ 'methods' ] , $ options [ 'magicMethods' ] ) ; if ( $ options [ 'extends' ] ) { $ methods += static :: _generateClassMethods ( $ options [ 'extends' ] , $ options [ 'layer' ] ) ; } $ methods += static :: _generateInterfaceMethods ( $ options [ 'implements' ] ) ; $ methods = $ methods ? '    ' . join ( "\n    " , $ methods ) : '' ; $ openTag = $ options [ 'openTag' ] ? "<?php\n" : '' ; $ closeTag = $ options [ 'closeTag' ] ? "?>" : '' ; return $ openTag . $ namespace .  <<<EOT

class {$class}{$extends}{$implements} {

{$uses}{$methods}

}
$closeTag
EOT ; }
Creates a class definition.

@param  array  $options Array of options. Options are:
- `'class'`      _string_ : the fully-namespaced class name.
- `'extends'`    _string_ : the fully-namespaced parent class name.
- `'implements'` _array_  : the implemented interfaces.
- `'uses'`       _array_  : the used traits.
- `'methods'`    _array_  : the methods to stubs.
- `'layer'`      _boolean_: indicate if public methods should be layered.
@return string          The generated class string content.
Creates a class definition .