/** * @return static BCrypt Instance */ public static function instance() { if (isset(static::$cache['hash']) && is_object(static::$cache['hash'])) { return static::$cache['hash']; } return static::$cache['hash'] = BCrypt::make(); }
public function testCreateHashByCryptMockInstance() { $hash = m::mock('Cygnite\\Hash\\BCrypt'); $this->assertInstanceOf('Cygnite\\Hash\\BCrypt', $hash); $crypt = Hash::instance(); $this->assertEquals(BCrypt::make(), $crypt); $this->assertInstanceOf('Cygnite\\Hash\\BCrypt', BCrypt::make()); }