Passed
Pull Request — master (#207)
by
unknown
16:03 queued 05:02
created

Document::getObjectIdentifier()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace EWW\Dpf\Domain\Model;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
use EWW\Dpf\Domain\Workflow\DocumentWorkflow;
18
use EWW\Dpf\Helper\InternalFormat;
19
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
20
21
22
/**
23
 * Document
24
 */
25
class Document extends AbstractEntity
26
{
27
    // xml data size ist limited to 64 KB
28
    const XML_DATA_SIZE_LIMIT = 64 * 1024;
29
30
    /**
31
     * title
32
     *
33
     * @var string
34
     */
35
    protected $title = '';
36
37
    /**
38
     * authors
39
     *
40
     * @var string
41
     */
42
    protected $authors = '';
43
44
    /**
45
     * xmlData
46
     *
47
     * @var string
48
     */
49
    protected $xmlData = '';
50
51
    /**
52
     * slubInfoData
53
     *
54
     * @var string
55
     */
56
    protected $slubInfoData = '';
57
58
    /**
59
     * documentType
60
     *
61
     * @var \EWW\Dpf\Domain\Model\DocumentType
62
     */
63
    protected $documentType = null;
64
65
    /**
66
     * objectIdentifier
67
     *
68
     * @var string
69
     */
70
    protected $objectIdentifier = '';
71
72
    /**
73
     * reservedObjectIdentifier
74
     *
75
     * @var string
76
     */
77
    protected $reservedObjectIdentifier;
78
79
    /**
80
     * transferStatus
81
     *
82
     * @var string
83
     */
84
    protected $transferStatus;
85
86
    /**
87
     *  transferDate
88
     *
89
     * @var integer
90
     */
91
    protected $transferDate;
92
93
    /**
94
     * changed
95
     *
96
     * @var boolean
97
     */
98
    protected $changed = false;
99
100
    /**
101
     * valid
102
     *
103
     * @var boolean
104
     */
105
    protected $valid = false;
106
107
    /**
108
     *
109
     * @var string $dateIssued
110
     */
111
    protected $dateIssued;
112
113
    /**
114
     *
115
     * @var string $processNumber
116
     */
117
    protected $processNumber = '';
118
119
    /**
120
     * @var bool $suggestion
121
     */
122
    protected $suggestion = false;
123
124
    /**
125
     * creator
126
     *
127
     * @var int
128
     */
129
    protected $creator = 0;
130
131
    /**
132
     * creation date
133
     *
134
     * @var string
135
     */
136
    protected $creationDate = "";
137
138
    /**
139
     * state
140
     *
141
     * @var string
142
     */
143
    protected $state = DocumentWorkflow::STATE_NONE_NONE;
144
145
    /**
146
     * temporary
147
     *
148
     * @var boolean
149
     */
150
    protected $temporary = FALSE;
151
152
    /**
153
     * remoteLastModDate
154
     *
155
     * @var string
156
     */
157
    protected $remoteLastModDate = '';
158
159
    /**
160
     * tstamp
161
     *
162
     * @var integer
163
     */
164
    protected $tstamp;
165
166
    /**
167
     * crdate
168
     *
169
     * @var integer
170
     */
171
    protected $crdate;
172
173
    /**
174
     * @var string
175
     */
176
    protected $linkedUid = '';
177
178
    /**
179
     * @var string
180
     */
181
    protected $comment = '';
182
183
    /**
184
     * date
185
     *
186
     * @var \DateTime
187
     */
188
    protected $embargoDate = null;
189
190
    /**
191
     * newlyAssignedFobIdentifiers
192
     *
193
     * @var array
194
     */
195
    protected $newlyAssignedFobIdentifiers = [];
196
197
    /**
198
     * @var bool
199
     */
200
    protected $stateChange = false;
201
202
    /**
203
     * file
204
     *
205
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EWW\Dpf\Domain\Model\File>
206
     * @TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")
207
     */
208
    protected $file = null;
209
210
    const TRANSFER_ERROR = "ERROR";
211
    const TRANSFER_QUEUED = "QUEUED";
212
    const TRANSFER_SENT = "SENT";
213
214
    /**
215
     * __construct
216
     */
217
    public function __construct()
218
    {
219
        //Do not remove the next line: It would break the functionality
220
        $this->initStorageObjects();
221
    }
222
223
    /**
224
     * Initializes all ObjectStorage properties
225
     *
226
     * @return void
227
     */
228
    protected function initStorageObjects()
229
    {
230
        $this->file = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
231
        $this->initCreationDate();
232
    }
233
234
    /**
235
     * Returns the title
236
     *
237
     * @return string $title
238
     */
239
    public function getTitle()
240
    {
241
        return $this->title;
242
    }
243
244
    /**
245
     * Sets the title
246
     *
247
     * @param string $title
248
     * @return void
249
     */
250
    public function setTitle($title)
251
    {
252
        $this->title = $title ?? '';
253
        //htmlspecialchars_decode($title,ENT_QUOTES);
254
    }
255
256
    /**
257
     * Returns the authors
258
     *
259
     * @return array $authors
260
     */
261
    public function getAuthors()
262
    {
263
        $authors = @unserialize($this->authors);
264
        if (is_array($authors)) {
265
            return $authors;
266
        } else {
267
            return [];
268
        }
269
    }
270
271
    /**
272
     * Sets the authors
273
     *
274
     * @param array $authors
275
     * @return void
276
     */
277
    public function setAuthors($authors)
278
    {
279
        $this->authors = serialize($authors);
280
    }
281
282
    /**
283
     * Returns the xmlData
284
     *
285
     * @return string $xmlData
286
     */
287
    public function getXmlData()
288
    {
289
        return $this->xmlData;
290
    }
291
292
    /**
293
     * Sets the xmlData
294
     *
295
     * @param string $xmlData
296
     * @return void
297
     */
298
    public function setXmlData($xmlData)
299
    {
300
        $this->xmlData = $xmlData;
301
    }
302
303
    /**
304
     * Returns the XML taking into account any existing embargo
305
     *
306
     * @return string
307
     */
308
    public function publicXml(): string
309
    {
310
        $internalFormat = new InternalFormat($this->getXmlData());
311
        $currentDate = new \DateTime('now');
312
        if ($currentDate < $this->getEmbargoDate()) {
313
            $internalFormat->removeAllFiles();
314
        } else {
315
            $internalFormat->completeFileData($this->getFile());
316
        }
317
318
        return $internalFormat->getXml();
319
    }
320
321
    /**
322
     * Returns the slubInfoData
323
     *
324
     * @return string $slubInfoData
325
     */
326
    public function getSlubInfoData()
327
    {
328
        return $this->slubInfoData;
329
    }
330
331
    /**
332
     * Sets the slubInfoData
333
     *
334
     * @return string $slubInfoData
335
     */
336
    public function setSlubInfoData($slubInfoData)
337
    {
338
        $this->slubInfoData = $slubInfoData;
339
    }
340
341
    /**
342
     * Returns the documentType
343
     *
344
     * @return \EWW\Dpf\Domain\Model\DocumentType $documentType
345
     */
346
    public function getDocumentType()
347
    {
348
        return $this->documentType;
349
    }
350
351
    /**
352
     * Sets the documentType
353
     *
354
     * @param \EWW\Dpf\Domain\Model\DocumentType $documentType
355
     * @return void
356
     */
357
    public function setDocumentType(\EWW\Dpf\Domain\Model\DocumentType $documentType)
358
    {
359
        $this->documentType = $documentType;
360
    }
361
362
    /**
363
     * Returns the objectIdentifier
364
     *
365
     * @return string
366
     */
367
    public function getObjectIdentifier()
368
    {
369
        return $this->objectIdentifier;
370
    }
371
372
    /**
373
     * Sets the objectIdentifier
374
     *
375
     * @param string $objectIdentifier
376
     * @return void
377
     */
378
    public function setObjectIdentifier($objectIdentifier)
379
    {
380
        // Due to uniqe key uc_object_identifier, which should ignore empty object identifiers.
381
        $this->objectIdentifier = empty($objectIdentifier)? null : $objectIdentifier;
382
    }
383
384
    /**
385
     * Returns the reservedObjectIdentifier
386
     *
387
     * @return string
388
     */
389
    public function getReservedObjectIdentifier()
390
    {
391
        return $this->reservedObjectIdentifier;
392
    }
393
394
    /**
395
     * Sets the reservedObjectIdentifier
396
     *
397
     * @param string $reservedObjectIdentifier
398
     * @return void
399
     */
400
    public function setReservedObjectIdentifier($reservedObjectIdentifier)
401
    {
402
        $this->reservedObjectIdentifier = $reservedObjectIdentifier;
403
    }
404
405
    /**
406
     * Returns the transferStatus
407
     *
408
     * @return string
409
     */
410
    public function getTransferStatus()
411
    {
412
        return $this->transferStatus;
413
    }
414
415
    /**
416
     * Sets the transferStatus
417
     *
418
     * @param string
419
     * @return void
420
     */
421
    public function setTransferStatus($transferStatus)
422
    {
423
        $this->transferStatus = $transferStatus;
424
    }
425
426
    /**
427
     * Returns the transferDate
428
     *
429
     * @return integer
430
     */
431
    public function getTransferDate()
432
    {
433
        return $this->transferDate;
434
    }
435
436
    /**
437
     * Sets the transferDate
438
     *
439
     * @param integer $transferDate
440
     * @return void
441
     */
442
    public function setTransferDate($transferDate)
443
    {
444
        $this->transferDate = $transferDate;
445
    }
446
447
    /**
448
     * Returns the transferErrorCode
449
     *
450
     * @var integer
451
     */
452
    public function getTransferErrorCode()
453
    {
454
        return $this->transferErrorCode;
455
    }
456
457
    /**
458
     * Sets the transferErrorCode
459
     *
460
     * @param integer $transferErrorCode
461
     * @return void
462
     */
463
    public function setTransferErrorCode($transferErrorCode)
464
    {
465
        $this->transferErrorCode = $transferErrorCode;
0 ignored issues
show
Bug Best Practice introduced by
The property transferErrorCode does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
466
    }
467
468
    /**
469
     * Returns the transferResponse
470
     *
471
     * @var string
472
     */
473
    public function getTransferResponse()
474
    {
475
        return $this->transferResponse;
476
    }
477
478
    /**
479
     * Sets the transferResponse
480
     *
481
     * @param string $transferResponse
482
     * @return void
483
     */
484
    public function setTransferResponse($transferResponse)
485
    {
486
        $this->transferResponse = $transferResponse;
0 ignored issues
show
Bug Best Practice introduced by
The property transferResponse does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
487
    }
488
489
    /**
490
     * Returns the transferHttpStatus
491
     *
492
     * @var integer
493
     */
494
    public function getTransferHttpStatus()
495
    {
496
        return $this->transferHttpStatus;
497
    }
498
499
    /**
500
     * Sets the transferHttpStatus
501
     *
502
     * @param integer $transferHttpStatus
503
     * @return void
504
     */
505
    public function setTransferHttpStatus($transferHttpStatus)
506
    {
507
        $this->transferHttpStatus = $transferHttpStatus;
0 ignored issues
show
Bug Best Practice introduced by
The property transferHttpStatus does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
508
    }
509
510
    /**
511
     * Adds a File
512
     *
513
     * @param \EWW\Dpf\Domain\Model\File $file
514
     * @return void
515
     */
516
    public function addFile(\EWW\Dpf\Domain\Model\File $file)
517
    {
518
        $this->file->attach($file);
519
    }
520
521
    /**
522
     * Removes a File
523
     *
524
     * @param \EWW\Dpf\Domain\Model\File $fileToRemove The File to be removed
525
     * @return void
526
     */
527
    public function removeFile(\EWW\Dpf\Domain\Model\File $fileToRemove)
528
    {
529
        $this->file->detach($fileToRemove);
530
    }
531
532
    /**
533
     * Returns the file
534
     *
535
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EWW\Dpf\Domain\Model\File> $file
536
     */
537
    public function getFile()
538
    {
539
        return $this->file;
540
    }
541
542
    /**
543
     * Sets the file
544
     *
545
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EWW\Dpf\Domain\Model\File> $file
546
     * @return void
547
     */
548
    public function setFile(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $file)
549
    {
550
        $this->file = $file;
551
    }
552
553
    /**
554
     * @param string $fileIdentifier
555
     * @return \EWW\Dpf\Domain\Model\File|null
556
     */
557
    public function getFileByFileIdentifier(string $fileIdentifier): ?\EWW\Dpf\Domain\Model\File
558
    {
559
        foreach ($this->file as $file) {
560
            if ($file->getFileIdentifier() == $fileIdentifier) {
561
                return $file;
562
            }
563
        }
564
        return null;
565
    }
566
567
    /**
568
     * @return \EWW\Dpf\Domain\Model\File|null
569
     */
570
    public function getPrimaryFile(): ?\EWW\Dpf\Domain\Model\File
571
    {
572
        /** @var File $file */
573
        foreach ($this->file as $file) {
574
            if ($file->isPrimaryFile()) {
575
                return $file;
576
            }
577
        }
578
        return null;
579
    }
580
581
    /**
582
     * Has files
583
     */
584
    public function hasFiles()
585
    {
586
        if (is_a($this->getFile(), '\TYPO3\CMS\Extbase\Persistence\ObjectStorage')) {
587
            foreach ($this->getFile() as $file) {
588
                /** @var File $file */
589
                if (!$file->isFileGroupDeleted()) {
590
                    return true;
591
                }
592
            }
593
        }
594
595
        return false;
596
    }
597
598
    /**
599
     * Returns the changed
600
     *
601
     * @return boolean $changed
602
     */
603
    public function getChanged()
604
    {
605
        return $this->changed;
606
    }
607
608
    /**
609
     * Sets the changed
610
     *
611
     * @param boolean $changed
612
     * @return void
613
     */
614
    public function setChanged($changed)
615
    {
616
        $this->changed = boolval($changed);
617
    }
618
619
    /**
620
     * Returns the valid
621
     *
622
     * @return boolean $valid
623
     */
624
    public function getValid()
625
    {
626
        return $this->valid;
627
    }
628
629
    /**
630
     * Sets the valid
631
     *
632
     * @param boolean $valid
633
     * @return void
634
     */
635
    public function setValid($valid)
636
    {
637
        $this->valid = boolval($valid);
638
    }
639
640
    /**
641
     * Gets the Issue Date
642
     *
643
     * @return string
644
     */
645
    public function getDateIssued()
646
    {
647
        return empty($this->dateIssued) ? '' : $this->dateIssued;
648
    }
649
650
    /**
651
     * Sets the Issue Date
652
     *
653
     * @param string $dateIssued
654
     * @return void
655
     */
656
    public function setDateIssued($dateIssued)
657
    {
658
        $this->dateIssued = empty($dateIssued) ? '' : $dateIssued;
659
    }
660
661
662
    /**
663
     * Returns the process number
664
     *
665
     * @return string
666
     */
667
    public function getProcessNumber()
668
    {
669
        return $this->processNumber;
670
    }
671
672
    /**
673
     * Sets the process number
674
     *
675
     * @param string $processNumber
676
     * @return void
677
     */
678
    public function setProcessNumber($processNumber)
679
    {
680
        $this->processNumber = trim($processNumber);
681
    }
682
683
684
    /**
685
     * Gets the submitter name of the document
686
     *
687
     * @return string
688
     */
689
    public function getSubmitterName()
690
    {
691
        try {
692
            $internalFormat = new InternalFormat($this->getXmlData());
693
            return $internalFormat->getSubmitterName();
694
        } catch (\Exception $exception) {
695
            return "";
696
        }
697
    }
698
699
    /**
700
     * Gets the primary urn of the document
701
     *
702
     * @return string
703
     */
704
    public function getPrimaryUrn()
705
    {
706
        $internalFormat = new InternalFormat($this->getXmlData());
707
        return $internalFormat->getPrimaryUrn();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $internalFormat->getPrimaryUrn() could also return false which is incompatible with the documented return type string. Did you maybe forget to handle an error condition?

If the returned type also contains false, it is an indicator that maybe an error condition leading to the specific return statement remains unhandled.

Loading history...
708
    }
709
710
    /**
711
     * Returns the creator feuser uid
712
     *
713
     * @return int
714
     */
715
    public function getCreator()
716
    {
717
        return $this->creator? $this->creator : 0;
718
    }
719
720
    /**
721
     * Sets the creator feuser uid
722
     *
723
     * @param int $creator
724
     * @return void
725
     */
726
    public function setCreator($creator)
727
    {
728
        $this->creator = $creator;
729
    }
730
731
    public function getState()
732
    {
733
        return $this->state;
734
    }
735
736
    public function setState($state)
737
    {
738
        $this->stateChange = $this->state != $state;
739
        $this->state = $state;
740
    }
741
742
    public function getRemoteState()
743
    {
744
        $state = explode(':', $this->state);
745
        if (is_array($state) && array_key_exists(1, $state)) {
746
            return $state[1];
747
        }
748
        return DocumentWorkflow::REMOTE_STATE_NONE;
749
    }
750
751
    public function getLocalState() {
752
        $state = explode(':', $this->state);
753
        if (is_array($state) && array_key_exists(0, $state)) {
754
            return $state[0];
755
        }
756
        return DocumentWorkflow::LOCAL_STATE_NONE;
757
    }
758
759
    /**
760
     * Returns if a document is a temporary document.
761
     *
762
     * @return boolean $temporary
763
     */
764
    public function isTemporary() {
765
        return $this->temporary;
766
    }
767
768
    /**
769
     * Sets if a document is a temporary document or not.
770
     *
771
     * @param boolean $temporary
772
     * @return void
773
     */
774
    public function setTemporary($temporary) {
775
        $this->temporary = boolval($temporary);
776
    }
777
778
    /**
779
     * @return string
780
     */
781
    public function getRemoteLastModDate()
782
    {
783
        return $this->remoteLastModDate;
784
    }
785
786
    /**
787
     * @param string $remoteLastModDate
788
     * @return void
789
     */
790
    public function setRemoteLastModDate($remoteLastModDate)
791
    {
792
        $this->remoteLastModDate = $remoteLastModDate;
793
    }
794
795
    /**
796
     * @return integer
797
     */
798
    public function getTstamp()
799
    {
800
        return $this->tstamp;
801
    }
802
803
    /**
804
     * @return integer
805
     */
806
    public function getCrdate()
807
    {
808
        return $this->crdate;
809
    }
810
811
    /**
812
     * @return bool
813
     */
814
    public function isSuggestion(): bool
815
    {
816
        return $this->suggestion;
817
    }
818
819
    /**
820
     * @param bool $suggestion
821
     */
822
    public function setSuggestion(bool $suggestion)
823
    {
824
        $this->suggestion = boolval($suggestion);
825
    }
826
827
    /**
828
     * @return string
829
     */
830
    public function getLinkedUid(): string
831
    {
832
        return $this->linkedUid;
833
    }
834
835
    /**
836
     * @param string $linkedUid
837
     */
838
    public function setLinkedUid(string $linkedUid)
839
    {
840
        $this->linkedUid = $linkedUid;
841
    }
842
843
    /**
844
     * @return string
845
     */
846
    public function getComment(): string
847
    {
848
        return $this->comment;
849
    }
850
851
    /**
852
     * @param string $comment
853
     */
854
    public function setComment(string $comment)
855
    {
856
        $this->comment = $comment;
857
    }
858
859
    /**
860
     * Copies the data of the given document object into the current document object.
861
     *
862
     * @param Document $documentToCopy
863
     * @return $this
864
     * @throws \TYPO3\CMS\Extbase\Reflection\Exception\PropertyNotAccessibleException
865
     */
866
    public function copy(Document $documentToCopy) {
867
        $availableProperties = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getGettablePropertyNames($documentToCopy);
868
        $newDocument = $this;
869
870
        foreach ($availableProperties as $propertyName) {
871
            if (\TYPO3\CMS\Extbase\Reflection\ObjectAccess::isPropertySettable($newDocument, $propertyName)
872
                && !in_array($propertyName, array('uid','pid', 'file', 'comment', 'linkedUid', 'suggestion', 'creator'))) {
873
874
                $propertyValue = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getProperty($documentToCopy, $propertyName);
875
                \TYPO3\CMS\Extbase\Reflection\ObjectAccess::setProperty($newDocument, $propertyName, $propertyValue);
876
            }
877
        }
878
879
        return $this;
880
    }
881
882
    public function getNotes() {
883
        $internalFormat = new InternalFormat($this->getXmlData());
884
        return $internalFormat->getNotes();
885
    }
886
887
    /**
888
     * Gets the document Identifier
889
     *
890
     * @return string|int
891
     */
892
    public function getDocumentIdentifier()
893
    {
894
        return $this->getObjectIdentifier()? $this->getObjectIdentifier() : $this->getUid();
895
    }
896
897
    /**
898
     * Returns if a document is a working copy of a published document.
899
     *
900
     * @return bool
901
     */
902
    public function isWorkingCopy()
903
    {
904
        return $this->getObjectIdentifier() && !$this->isTemporary() && !$this->isSuggestion();
905
    }
906
907
908
    /**
909
     * Returns if a document is a temporary copy of a published document.
910
     *
911
     * @return bool
912
     */
913
    public function isTemporaryCopy()
914
    {
915
        return $this->getObjectIdentifier() && $this->isTemporary() && !$this->isSuggestion();
916
    }
917
918
919
    /**
920
     * Gets the publication year out of the mods-xml data.
921
     *
922
     * @return string|null
923
     */
924
    public function getPublicationYear()
925
    {
926
        $internalFormat = new InternalFormat($this->getXmlData());
927
        $year =  $internalFormat->getPublishingYear();
928
        return $year? $year : "";
929
    }
930
931
932
    /**
933
     * Gets the source information out of the mods-xml data.
934
     *
935
     * @return string|null
936
     */
937
    public function getSourceDetails()
938
    {
939
        $internalFormat = new InternalFormat($this->getXmlData());
940
        $data = $internalFormat->getSourceDetails();
941
        return $data;
942
    }
943
944
    /**
945
     * @return \DateTime|null
946
     */
947
    public function getEmbargoDate(): ?\DateTime
948
    {
949
        return $this->embargoDate;
950
    }
951
952
    /**
953
     * @param \DateTime|null $embargoDate
954
     */
955
    public function setEmbargoDate(?\DateTime $embargoDate)
956
    {
957
        $this->embargoDate = $embargoDate;
958
    }
959
960
    /**
961
     * @return array
962
     */
963
    public function getNewlyAssignedFobIdentifiers(): array
964
    {
965
        return $this->newlyAssignedFobIdentifiers;
966
    }
967
968
    /**
969
     * @param array newlyAssignedFobIdentifiers
0 ignored issues
show
Bug introduced by
The type EWW\Dpf\Domain\Model\newlyAssignedFobIdentifiers was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
970
     */
971
    public function setNewlyAssignedFobIdentifiers(array $newlyAssignedFobIdentifiers): void
972
    {
973
        $this->newlyAssignedFobIdentifiers = $newlyAssignedFobIdentifiers;
974
    }
975
976
    /**
977
     * @return array
978
     */
979
    public function getPreviouslyAssignedFobIdentifiers()
980
    {
981
        return array_diff(
982
            $this->getAssignedFobIdentifiers(), $this->getNewlyAssignedFobIdentifiers()
983
        );
984
    }
985
986
    /**
987
     * @return array
988
     */
989
    public function getAssignedFobIdentifiers(): array
990
    {
991
        $internalFormat = new InternalFormat($this->getXmlData());
992
        return $internalFormat->getPersonFisIdentifiers();
993
    }
994
995
    /**
996
     * @return bool
997
     */
998
    public function isStateChange(): bool
999
    {
1000
        return $this->stateChange;
1001
    }
1002
1003
    /**
1004
     * @return mixed
1005
     */
1006
    public function getDepositLicense()
1007
    {
1008
        $internalFormat = new InternalFormat($this->getXmlData());
1009
        $data = $internalFormat->getDepositLicense();
1010
        return $data;
1011
    }
1012
1013
    /**
1014
     * @return string
1015
     */
1016
    public function getCreationDate(): string
1017
    {
1018
        if (
1019
            $this->getRemoteState() == DocumentWorkflow::REMOTE_STATE_NONE
1020
            && empty($this->creationDate)
1021
        ) {
1022
            $date = new \DateTime();
1023
            $date->setTimestamp($this->crdate);
1024
            return $date->format(\DateTimeInterface::RFC3339_EXTENDED);
1025
        }
1026
1027
        return $this->creationDate;
1028
    }
1029
1030
    /**
1031
     * @param string $creationDate
1032
     */
1033
    public function setCreationDate(string $creationDate): void
1034
    {
1035
        $this->creationDate = $creationDate;
1036
    }
1037
1038
    /**
1039
     * Initializes the creation date with the current date.
1040
     */
1041
    public function initCreationDate(): void
1042
    {
1043
        $date = new \DateTime();
1044
        $this->setCreationDate($date->format(\DateTimeInterface::RFC3339_EXTENDED));
1045
    }
1046
}
1047