eZ\Publish\Core\MVC\Symfony\Security\User\Identity::getHash PHP Метод

getHash() публичный Метод

..).
public getHash ( ) : string
Результат string
    public function getHash()
    {
        if (!isset($this->hash)) {
            $hashArray = array();
            foreach ($this->identityInfo as $infoType => $infoValue) {
                $hashArray[] = "{$infoType}={$infoValue}";
            }
            $this->hash = sha1(implode('-', $hashArray));
        }
        return $this->hash;
    }

Usage Example

Пример #1
0
 /**
  * @covers eZ\Publish\Core\MVC\Symfony\Security\User\Identity::__construct
  * @covers eZ\Publish\Core\MVC\Symfony\Security\User\Identity::setInformation
  * @covers eZ\Publish\Core\MVC\Symfony\Security\User\Identity::getHash
  */
 public function testGetHash()
 {
     $identity = new Identity();
     $identity->setInformation('foo', 'bar');
     $hash1 = $identity->getHash();
     $this->assertInternalType('string', $hash1);
     $identity->setInformation('truc', 'muche');
     $hash2 = $identity->getHash();
     $this->assertInternalType('string', $hash2);
     $this->assertTrue($hash1 !== $hash2);
     $identity->setInformation('number', 123);
     $hash3 = $identity->getHash();
     $this->assertInternalType('string', $hash3);
     $this->assertTrue($hash3 !== $hash1);
     $this->assertTrue($hash3 !== $hash2);
     $identity->replaceInformation(array('foo' => 'bar'));
     $this->assertSame($hash1, $identity->getHash());
 }