| Total Complexity | 3 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | trait DomainObjectTimeTrait |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @var string Insertion date on persistent storage. |
||
| 24 | */ |
||
| 25 | public string $created = ''; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var string Last update date on persistento storage. |
||
| 29 | */ |
||
| 30 | public string $lastUpdate = ''; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Set the creation date for the object. |
||
| 34 | * |
||
| 35 | * @return void |
||
| 36 | * |
||
| 37 | * @throws UnexpectedValueException If the creation date on the object is already set. |
||
| 38 | */ |
||
| 39 | public function setCreated(): void |
||
| 40 | { |
||
| 41 | $date = \date(DATE_ATOM); |
||
| 42 | |||
| 43 | if ($this->created !== '') { |
||
| 44 | throw new UnexpectedValueException('Creation date property is immutable.'); |
||
| 45 | } |
||
| 46 | |||
| 47 | $this->created = $date; |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Set the time for the last object changes. |
||
| 52 | * |
||
| 53 | * @return void |
||
| 54 | */ |
||
| 55 | public function setLastUpdate(): void |
||
| 60 | } |
||
| 61 | } |
||
| 62 |