Mockery\Container::self PHP Method

self() public method

Retrieve the last remembered mock object, which is the same as saying retrieve the current mock being programmed where you have yet to call mock() to change it - thus why the method name is "self" since it will be be used during the programming of the same mock.
public self ( ) : Mock
return Mock
    public function self()
    {
        $mocks = array_values($this->_mocks);
        $index = count($mocks) - 1;
        return $mocks[$index];
    }

Usage Example

Example #1
0
 /**
  * Static shortcut to \Mockery\Container::self()
  *
  * @return \Mockery\MockInterface
  */
 public static function self()
 {
     if (is_null(self::$_container)) {
         throw new \LogicException("You have not declared any mocks yet");
     }
     return self::$_container->self();
 }