Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 25 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
Attachment | |
0.00% |
0 / 25 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
2 | |||
decodeId | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | /** @noinspection PhpUnhandledExceptionInspection */ |
3 | declare(strict_types=1); |
4 | |
5 | class Attachment extends DataCollectionTypeSafe { |
6 | |
7 | const dataTypes = ['image', 'missing']; |
8 | const attachmentTypes = ['capture-image']; |
9 | |
10 | public readonly string $attachmentId; |
11 | public readonly string $attachmentType; |
12 | public readonly string $dataType; |
13 | public readonly array $attachmentFileIds; |
14 | public readonly ?int $lastModified; |
15 | public readonly string $_groupName; |
16 | public readonly string $_groupLabel; |
17 | public readonly string $_loginName; |
18 | public readonly string $_loginNameSuffix; |
19 | public readonly string $testLabel; |
20 | public readonly string $_bookletName; |
21 | public readonly string $unitLabel; |
22 | public readonly string $personLabel; |
23 | public readonly int $_testId; |
24 | public readonly string $_unitName; |
25 | public readonly string $variableId; |
26 | |
27 | public function __construct( |
28 | string $attachmentId, |
29 | string $attachmentType, |
30 | string $dataType, |
31 | array $attachmentFileIds, |
32 | ?int $lastModified, |
33 | string $groupName, |
34 | string $groupLabel, |
35 | string $loginName, |
36 | string $loginNameSuffix, |
37 | string $testLabel, |
38 | string $bookletName, |
39 | string $unitLabel, |
40 | ) { |
41 | |
42 | $this->attachmentId = $attachmentId; |
43 | $this->attachmentType = $attachmentType; // TODO check |
44 | $this->dataType = $dataType; // TODO check |
45 | $this->attachmentFileIds = $attachmentFileIds; |
46 | $this->lastModified = $lastModified; |
47 | $this->_groupName = $groupName; |
48 | $this->_groupLabel = $groupLabel; |
49 | $this->_loginName = $loginName; |
50 | $this->_loginNameSuffix = $loginNameSuffix; |
51 | $this->_bookletName = $bookletName; |
52 | $this->testLabel = $testLabel; |
53 | $this->unitLabel = $unitLabel; |
54 | |
55 | $this->personLabel = AccessSet::getDisplayName( |
56 | $groupLabel, |
57 | $loginName, |
58 | $loginNameSuffix |
59 | ); |
60 | |
61 | $idPieces = self::decodeId($attachmentId); |
62 | $this->_testId = (int) $idPieces[0]; |
63 | $this->_unitName = $idPieces[1]; |
64 | $this->variableId = $idPieces[2]; |
65 | } |
66 | |
67 | static function decodeId(string $attachmentId): array { |
68 | |
69 | $idPieces = explode(':', $attachmentId); |
70 | if (count($idPieces) != 3) { |
71 | throw new HttpError("Invalid attachment attachmentId: `$attachmentId`", 400); |
72 | } |
73 | return $idPieces; |
74 | } |
75 | } |