| Total Complexity | 7 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | trait PublishableTrait |
||
| 20 | { |
||
| 21 | // Needs to be protected instead of published so reflection can read property when merging draft into published |
||
| 22 | protected ?\DateTimeInterface $publishedAt = null; |
||
| 23 | |||
| 24 | protected ?self $publishedResource = null; |
||
| 25 | |||
| 26 | protected ?self $draftResource = null; |
||
| 27 | |||
| 28 | /** @return static */ |
||
| 29 | public function setPublishedAt(?\DateTimeInterface $publishedAt) |
||
| 30 | { |
||
| 31 | $this->publishedAt = $publishedAt; |
||
| 32 | |||
| 33 | return $this; |
||
| 34 | } |
||
| 35 | |||
| 36 | public function getPublishedAt(): ?\DateTimeInterface |
||
| 37 | { |
||
| 38 | return $this->publishedAt; |
||
| 39 | } |
||
| 40 | |||
| 41 | public function isPublished(): bool |
||
| 42 | { |
||
| 43 | return null !== $this->publishedAt && new \DateTimeImmutable() >= $this->publishedAt; |
||
| 44 | } |
||
| 45 | |||
| 46 | /** @return static */ |
||
| 47 | public function setPublishedResource($publishedResource) |
||
| 48 | { |
||
| 49 | $this->publishedResource = $publishedResource; |
||
| 50 | |||
| 51 | return $this; |
||
| 52 | } |
||
| 53 | |||
| 54 | public function getPublishedResource(): ?self |
||
| 57 | } |
||
| 58 | |||
| 59 | public function getDraftResource(): ?self |
||
| 60 | { |
||
| 62 | } |
||
| 63 | } |
||
| 64 |