Dotink\Parody\Mime::onNew PHP Method

onNew() public method

This is useful if the code you are testing has a call such as new Class(). Since the code is dependent on that object, but it is not injected we essentially want to delay our method/property configuration for the mock till after that call. Once the factory is run it is removed from the stack automatically.
public onNew ( ) : Mime
return Mime The mime for method chaining
    public function onNew()
    {
        $expectation = array_slice(func_get_args(), 0, -1);
        $factory = array_slice(func_get_args(), -1)[0];
        if (!isset(self::$factories[$this->class])) {
            self::$factories[$this->class] = array();
        }
        self::$factories[$this->class][] = ['expectation' => $expectation, 'factory' => $factory];
        return $this;
    }