mirror of
https://gh.wpcy.net/https://github.com/fairpm/mini-fair-repo.git
synced 2026-04-25 07:55:45 +08:00
40 lines
741 B
PHP
40 lines
741 B
PHP
<?php
|
|
|
|
namespace MiniFAIR\PLC;
|
|
|
|
use Exception;
|
|
use JsonSerializable;
|
|
|
|
class SignedOperation extends Operation implements JsonSerializable {
|
|
public readonly string $sig;
|
|
|
|
public function __construct(
|
|
Operation $operation,
|
|
string $sig,
|
|
) {
|
|
parent::__construct(
|
|
$operation->type,
|
|
$operation->rotationKeys,
|
|
$operation->verificationMethods,
|
|
$operation->alsoKnownAs,
|
|
$operation->services,
|
|
$operation->prev,
|
|
);
|
|
|
|
$this->sig = $sig;
|
|
}
|
|
|
|
public function validate() : bool {
|
|
if ( empty( $this->sig ) ) {
|
|
throw new Exception( 'Signature is empty' );
|
|
}
|
|
|
|
return parent::validate();
|
|
}
|
|
|
|
public function jsonSerialize() : array {
|
|
$data = parent::jsonSerialize();
|
|
$data['sig'] = $this->sig;
|
|
return $data;
|
|
}
|
|
}
|