public function __construct($dir = ".", $cookieCode = "", $serviceName = "none") { if ($cookieCode == "") { $cookieCode = md5(rand()); } $this->dir = $dir; $this->cookieCode = $cookieCode; $this->twofactorAdapter = new twofactorAdapter(); $this->twofactorAdapter->setDir($this->dir); $this->twofactorAdapter->setServiceName($serviceName); $secret = $this->readSecret(); if ($secret && $secret != 1) { //I have a secret stored, so I set it as secret $this->twofactorAdapter->setSecret($secret); } else { //I don't have a secret stored so I store the secret generated by library $this->storeSecret($this->twofactorAdapter->getSecret()); } $this->secret = $this->twofactorAdapter->getSecret(); }
public function testClone() { $twofactorAdapter = new twofactorAdapter(); $twofactorAdapter2 = clone $twofactorAdapter; $this->assertEquals($twofactorAdapter2->getSecret(), $twofactorAdapter->getSecret()); }