Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| Document | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isAccepted | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isDraft | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** @license For full copyright and license information, please see the LICENSE.md file. */ |
| 6 | |
| 7 | namespace App\Modules\Documents\Domain\Model; |
| 8 | |
| 9 | defined('AMMONLY_APP') || exit('Direct script access is forbidden.'); |
| 10 | |
| 11 | /** |
| 12 | * Domain model representing a Document entity. |
| 13 | * |
| 14 | * @package App\Modules\Documents\Domain\Model |
| 15 | */ |
| 16 | final readonly class Document |
| 17 | { |
| 18 | /** |
| 19 | * Document constructor. |
| 20 | * |
| 21 | * @param int $id Unique record identifier. |
| 22 | * @param string $documentName Title or filename of the document. |
| 23 | * @param string $documentType Document kind: document, note, or file. |
| 24 | * @param string $documentStatus Current state: draft, verification, accepted, rejected. |
| 25 | * @param string|null $expiryDate Optional validity expiration date (YYYY-MM-DD). |
| 26 | * @param string|null $extension File extension or format tag (e.g. pdf, docx). |
| 27 | * @param string|null $linkUrl Optional external document URL. |
| 28 | * @param string|null $leadIn Executive summary or lead-in text. |
| 29 | * @param string|null $description Full document content or detailed description. |
| 30 | * @param string $currentVersion Current semantic version string (e.g. 1.0). |
| 31 | * @param int|null $companyId Associated company identifier. |
| 32 | * @param int|null $contactId Associated contact identifier. |
| 33 | * @param int|null $projectId Associated project identifier. |
| 34 | * @param int|null $taskId Associated project task identifier. |
| 35 | * @param int|null $contractId Associated contract identifier. |
| 36 | * @param int|null $ticketId Associated support ticket identifier. |
| 37 | * @param bool $isActive Active state flag. |
| 38 | * @param int $createdBy Creator user identifier. |
| 39 | * @param int $owner Owner user identifier. |
| 40 | * @param string $createdAt Record creation timestamp. |
| 41 | * @param string $updatedAt Record modification timestamp. |
| 42 | * @param int $recordStatus System record status (1=active, 0=archived). |
| 43 | */ |
| 44 | public function __construct( |
| 45 | public int $id, |
| 46 | public string $documentName, |
| 47 | public string $documentType = 'document', |
| 48 | public string $documentStatus = 'draft', |
| 49 | public ?string $expiryDate = null, |
| 50 | public ?string $extension = null, |
| 51 | public ?string $linkUrl = null, |
| 52 | public ?string $leadIn = null, |
| 53 | public ?string $description = null, |
| 54 | public string $currentVersion = '1.0', |
| 55 | public ?int $companyId = null, |
| 56 | public ?int $contactId = null, |
| 57 | public ?int $projectId = null, |
| 58 | public ?int $taskId = null, |
| 59 | public ?int $contractId = null, |
| 60 | public ?int $ticketId = null, |
| 61 | public bool $isActive = true, |
| 62 | public int $createdBy = 1, |
| 63 | public int $owner = 1, |
| 64 | public string $createdAt = '', |
| 65 | public string $updatedAt = '', |
| 66 | public int $recordStatus = 1, |
| 67 | ) { |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Indicates whether the document has been approved for production use. |
| 72 | * |
| 73 | * @return bool True if accepted, false otherwise. |
| 74 | */ |
| 75 | public function isAccepted(): bool |
| 76 | { |
| 77 | return $this->documentStatus === 'accepted'; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Indicates whether the document is still in draft state. |
| 82 | * |
| 83 | * @return bool True if draft, false otherwise. |
| 84 | */ |
| 85 | public function isDraft(): bool |
| 86 | { |
| 87 | return $this->documentStatus === 'draft'; |
| 88 | } |
| 89 | } |