Dotink\Parody\Mime::create PHP Метод

create() приватный статический Метод

Create a new quip (mocked object) of a particular class to work on.
private static create ( string $class, string $overload_static = FALSE ) : Mime
$class string The class from which to build the object
$overload_static string Whether or not the quip should overload static calls
Результат Mime The mime object for developing the object.
    private static function create($class, $overload_static = FALSE)
    {
        if (!class_exists($class, FALSE)) {
            self::make($class);
        }
        $class = self::qualify($class);
        $quip = new $class();
        if (!isset(self::$objects[$class]) || $overload_static) {
            self::$objects[$class] = $quip;
        }
        return $quip;
    }

Usage Example

Пример #1
0
<?php

namespace Dotink\Lab;

use Dotink\Parody\Mime;
return ['setup' => function ($data, $shared) {
    needs('src/Quip.php');
    needs('src/Mime.php');
}, 'tests' => ['Test' => function ($data, $shared) {
    $static = Mime::define('Bar');
    $instance = Mime::create('Bar')->onCall('foo')->give('bar');
    $static->onCall('foo')->give('bar');
    assert(\Bar::foo())->equals('bar');
    assert($instance()->foo())->equals('bar');
    $instance = $static->create()->onCall('foo')->give('bar');
    assert($instance()->foo())->equals('bar');
    $static->onNew('test', function ($mime) {
        $mime->onCall('foo')->give('foo');
    });
    $instance = new \Bar('test');
    assert($instance->foo())->equals('foo');
}]];
All Usage Examples Of Dotink\Parody\Mime::create