Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
24 / 24 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
| SignRequest | |
100.00% |
24 / 24 |
|
100.00% |
7 / 7 |
9 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
16 / 16 |
|
100.00% |
1 / 1 |
1 | |||
| getParticipantRoleEnum | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setParticipantRoleEnum | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isObserver | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasCompletedSigning | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |||
| getStatusEnum | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setStatusEnum | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | /** |
| 5 | * SPDX-FileCopyrightText: 2020-2024 LibreCode coop and contributors |
| 6 | * SPDX-License-Identifier: AGPL-3.0-or-later |
| 7 | */ |
| 8 | |
| 9 | namespace OCA\Libresign\Db; |
| 10 | |
| 11 | use OCA\Libresign\Enum\ParticipantRole; |
| 12 | use OCA\Libresign\Enum\SignRequestStatus; |
| 13 | use OCP\AppFramework\Db\Entity; |
| 14 | use OCP\DB\Types; |
| 15 | |
| 16 | /** |
| 17 | * @method void setId(int $uid) |
| 18 | * @method int getId() |
| 19 | * @method void setFileId(int $fileId) |
| 20 | * @method ?int getFileId() |
| 21 | * @method void setUuid(string $uuid) |
| 22 | * @method string getUuid() |
| 23 | * @method void setDescription(?string $description) |
| 24 | * @method ?string getDescription() |
| 25 | * @method void setCreatedAt(\DateTime $createdAt) |
| 26 | * @method \DateTime getCreatedAt() |
| 27 | * @method void setSigned(\DateTime $signed) |
| 28 | * @method ?\DateTime getSigned() |
| 29 | * @method void setSignedHash(string $hash) |
| 30 | * @method ?string getSignedHash() |
| 31 | * @method void setDisplayName(string $displayName) |
| 32 | * @method string getDisplayName() |
| 33 | * @method void setMetadata(array $metadata) |
| 34 | * @method ?array getMetadata() |
| 35 | * @method void setDocmdpLevel(int $docmdpLevel) |
| 36 | * @method int getDocmdpLevel() |
| 37 | * @method void setSigningOrder(int $signingOrder) |
| 38 | * @method int getSigningOrder() |
| 39 | * @method void setStatus(int $status) |
| 40 | * @method int getStatus() |
| 41 | * @method void setParticipantRole(string $participantRole) |
| 42 | * @method string getParticipantRole() |
| 43 | * @method void setRejectedAt(?\DateTime $rejectedAt) |
| 44 | * @method ?\DateTime getRejectedAt() |
| 45 | * @method void setRejectionComment(?string $rejectionComment) |
| 46 | * @method ?string getRejectionComment() |
| 47 | * @method void setRejectionCommentPrivate(bool $rejectionCommentPrivate) |
| 48 | * @method bool getRejectionCommentPrivate() |
| 49 | */ |
| 50 | class SignRequest extends Entity { |
| 51 | protected ?int $fileId = null; |
| 52 | protected string $uuid = ''; |
| 53 | protected string $displayName = ''; |
| 54 | protected ?string $description = null; |
| 55 | protected ?\DateTime $createdAt = null; |
| 56 | protected ?\DateTime $signed = null; |
| 57 | protected ?string $signedHash = null; |
| 58 | protected ?array $metadata = null; |
| 59 | protected int $docmdpLevel = 0; |
| 60 | protected int $signingOrder = 1; |
| 61 | protected int $status = 0; |
| 62 | protected string $participantRole = 'signer'; |
| 63 | protected ?\DateTime $rejectedAt = null; |
| 64 | protected ?string $rejectionComment = null; |
| 65 | protected bool $rejectionCommentPrivate = false; |
| 66 | |
| 67 | public function __construct() { |
| 68 | $this->addType('id', Types::INTEGER); |
| 69 | $this->addType('fileId', Types::INTEGER); |
| 70 | $this->addType('uuid', Types::STRING); |
| 71 | $this->addType('displayName', Types::STRING); |
| 72 | $this->addType('description', Types::STRING); |
| 73 | $this->addType('createdAt', Types::DATETIME); |
| 74 | $this->addType('signed', Types::DATETIME); |
| 75 | $this->addType('signedHash', Types::STRING); |
| 76 | $this->addType('metadata', Types::JSON); |
| 77 | $this->addType('docmdpLevel', Types::SMALLINT); |
| 78 | $this->addType('signingOrder', Types::INTEGER); |
| 79 | $this->addType('status', Types::SMALLINT); |
| 80 | $this->addType('participantRole', Types::STRING); |
| 81 | $this->addType('rejectedAt', Types::DATETIME); |
| 82 | $this->addType('rejectionComment', Types::STRING); |
| 83 | $this->addType('rejectionCommentPrivate', Types::BOOLEAN); |
| 84 | } |
| 85 | |
| 86 | public function getParticipantRoleEnum(): ParticipantRole { |
| 87 | return ParticipantRole::fromNullable($this->participantRole); |
| 88 | } |
| 89 | |
| 90 | public function setParticipantRoleEnum(ParticipantRole $role): void { |
| 91 | $this->setParticipantRole($role->value); |
| 92 | } |
| 93 | |
| 94 | public function isObserver(): bool { |
| 95 | return $this->getParticipantRoleEnum() === ParticipantRole::OBSERVER; |
| 96 | } |
| 97 | |
| 98 | public function hasCompletedSigning(): bool { |
| 99 | return $this->getStatusEnum() === SignRequestStatus::SIGNED |
| 100 | || $this->signed !== null |
| 101 | || $this->signedHash !== null; |
| 102 | } |
| 103 | |
| 104 | public function getStatusEnum(): SignRequestStatus { |
| 105 | return SignRequestStatus::from($this->status); |
| 106 | } |
| 107 | |
| 108 | public function setStatusEnum(SignRequestStatus $status): void { |
| 109 | $this->setStatus($status->value); |
| 110 | } |
| 111 | } |