setValue($value); $this->setAlgorithm($algorithm); $this->setCounter($counter); $this->setPublicKey($publicKey); } /** * @param $apiResult * * @return static */ public static function fromApiResult(object $apiResult): self { return new self( $apiResult->value, $apiResult->algorithm, (int)$apiResult->counter, $apiResult->public_key ); } /** * @param array $dbState * * @return static */ public static function fromDbState(array $dbState): self { return new self( $dbState['value'], $dbState['algorithm'], (int)$dbState['counter'], $dbState['public_key'] ); } /** * @return array */ public function toArray(): array { return [ 'value' => $this->getValue(), 'algorithm' => $this->getAlgorithm(), 'counter' => $this->getCounter(), 'public_key' => $this->getPublicKey(), ]; } /** * @return stdClass */ public function toApiResult(): stdClass { $apiResult = new stdClass(); $apiResult->value = $this->getValue(); $apiResult->algorithm = $this->getAlgorithm(); $apiResult->counter = $this->getCounter(); $apiResult->public_key = $this->getPublicKey(); return $apiResult; } /** * @return string */ public function getValue(): string { return $this->value; } /** * @param string $value */ public function setValue(string $value): void { $this->value = $value; } /** * @return string */ public function getAlgorithm(): string { return $this->algorithm; } /** * @param string $algorithm */ public function setAlgorithm(string $algorithm): void { $this->algorithm = $algorithm; } /** * @return int */ public function getCounter(): int { return $this->counter; } /** * @param int $counter */ public function setCounter(int $counter): void { $this->counter = $counter; } /** * @return string */ public function getPublicKey(): string { return $this->publicKey; } /** * @param string $publicKey */ public function setPublicKey(string $publicKey): void { $this->publicKey = $publicKey; } }