hash() публичный статический Метод

Generates a hash from an instance or a string.
public static hash ( mixed $reference ) : string
$reference mixed An instance or a fully namespaced class name.
Результат string A string hash.
Пример #1
0
 /**
  * The Constructor.
  *
  * @param object|string $reference An instance or a fully-namespaced class name.
  */
 public function __construct($reference, $static = false)
 {
     $this->_reference = $reference;
     if (is_object($reference)) {
         Suite::register(get_class($reference));
     }
     Suite::register(Suite::hash($reference));
 }
Пример #2
0
 /**
  * Constructor
  *
  * @param string|object $actual   A fully-namespaced class name or an object instance.
  * @param string        $expected The expected method method name to be called.
  */
 public function __construct($actual)
 {
     $actual = ltrim($actual, '\\');
     $this->_actual = $actual;
     Suite::register(Suite::hash($actual));
     $this->_message = new Message(['name' => $actual]);
     $this->_backtrace = Debugger::backtrace();
 }
Пример #3
0
 /**
  * Clears the registered references.
  *
  * @param string $reference An instance or a fully namespaced class name or `null` to clear all.
  */
 public static function reset($reference = null)
 {
     if ($reference === null) {
         static::$_registered = [];
         Suite::reset();
         return;
     }
     unset(static::$_registered[Suite::hash($reference)]);
 }
Пример #4
0
         $hash = Suite::hash($instance);
         Suite::register($hash);
         expect(Suite::registered($hash))->toBe(true);
     });
 });
 describe("::register()", function () {
     it("return `false` if the hash is not registered", function () {
         $instance = new stdClass();
         $hash = Suite::hash($instance);
         expect(Suite::registered($hash))->toBe(false);
     });
 });
 describe("::reset()", function () {
     it("clears registered hashes", function () {
         $instance = new stdClass();
         $hash = Suite::hash($instance);
         Suite::register($hash);
         expect(Suite::registered($hash))->toBe(true);
         Suite::reset();
         expect(Suite::registered($hash))->toBe(false);
     });
 });
 describe("->status()", function () {
     it("returns `0` if a specs suite passes", function () {
         $describe = $this->suite->describe("", function () {
             $this->it("passes", function () {
                 $this->expect(true)->toBe(true);
             });
         });
         $this->suite->run();
         expect($this->suite->status())->toBe(0);
Пример #5
0
 /**
  * Watch a message.
  *
  * @param string|object $actual A fully-namespaced class name or an object instance.
  * @param string        $method The expected method method name to be called.
  * @param object                A message instance.
  */
 protected function _watch($message)
 {
     $reference = $message->reference();
     if (!$reference) {
         Suite::register($message->name());
         return $message;
     }
     if (is_object($reference)) {
         Suite::register(get_class($reference));
     }
     Suite::register(Suite::hash($reference));
     return $message;
 }