| @@ 72-107 (lines=36) @@ | ||
| 69 | * @param bool $quotaExceeded |
|
| 70 | * @return bool |
|
| 71 | */ |
|
| 72 | public function isExpired($timestamp, $quotaExceeded = false){ |
|
| 73 | // No expiration if disabled |
|
| 74 | if (!$this->isEnabled()) { |
|
| 75 | return false; |
|
| 76 | } |
|
| 77 | ||
| 78 | // Purge to save space (if allowed) |
|
| 79 | if ($quotaExceeded && $this->canPurgeToSaveSpace) { |
|
| 80 | return true; |
|
| 81 | } |
|
| 82 | ||
| 83 | $time = $this->timeFactory->getTime(); |
|
| 84 | // Never expire dates in future e.g. misconfiguration or negative time |
|
| 85 | // adjustment |
|
| 86 | if ($time<$timestamp) { |
|
| 87 | return false; |
|
| 88 | } |
|
| 89 | ||
| 90 | // Purge as too old |
|
| 91 | if ($this->maxAge !== self::NO_OBLIGATION) { |
|
| 92 | $maxTimestamp = $time - ($this->maxAge * 86400); |
|
| 93 | $isOlderThanMax = $timestamp < $maxTimestamp; |
|
| 94 | } else { |
|
| 95 | $isOlderThanMax = false; |
|
| 96 | } |
|
| 97 | ||
| 98 | if ($this->minAge !== self::NO_OBLIGATION) { |
|
| 99 | // older than Min obligation and we are running out of quota? |
|
| 100 | $minTimestamp = $time - ($this->minAge * 86400); |
|
| 101 | $isMinReached = ($timestamp < $minTimestamp) && $quotaExceeded; |
|
| 102 | } else { |
|
| 103 | $isMinReached = false; |
|
| 104 | } |
|
| 105 | ||
| 106 | return $isOlderThanMax || $isMinReached; |
|
| 107 | } |
|
| 108 | ||
| 109 | /** |
|
| 110 | * @return bool|int |
|
| @@ 78-113 (lines=36) @@ | ||
| 75 | * @param bool $quotaExceeded |
|
| 76 | * @return bool |
|
| 77 | */ |
|
| 78 | public function isExpired($timestamp, $quotaExceeded = false){ |
|
| 79 | // No expiration if disabled |
|
| 80 | if (!$this->isEnabled()) { |
|
| 81 | return false; |
|
| 82 | } |
|
| 83 | ||
| 84 | // Purge to save space (if allowed) |
|
| 85 | if ($quotaExceeded && $this->canPurgeToSaveSpace) { |
|
| 86 | return true; |
|
| 87 | } |
|
| 88 | ||
| 89 | $time = $this->timeFactory->getTime(); |
|
| 90 | // Never expire dates in future e.g. misconfiguration or negative time |
|
| 91 | // adjustment |
|
| 92 | if ($time<$timestamp) { |
|
| 93 | return false; |
|
| 94 | } |
|
| 95 | ||
| 96 | // Purge as too old |
|
| 97 | if ($this->maxAge !== self::NO_OBLIGATION) { |
|
| 98 | $maxTimestamp = $time - ($this->maxAge * 86400); |
|
| 99 | $isOlderThanMax = $timestamp < $maxTimestamp; |
|
| 100 | } else { |
|
| 101 | $isOlderThanMax = false; |
|
| 102 | } |
|
| 103 | ||
| 104 | if ($this->minAge !== self::NO_OBLIGATION) { |
|
| 105 | // older than Min obligation and we are running out of quota? |
|
| 106 | $minTimestamp = $time - ($this->minAge * 86400); |
|
| 107 | $isMinReached = ($timestamp < $minTimestamp) && $quotaExceeded; |
|
| 108 | } else { |
|
| 109 | $isMinReached = false; |
|
| 110 | } |
|
| 111 | ||
| 112 | return $isOlderThanMax || $isMinReached; |
|
| 113 | } |
|
| 114 | ||
| 115 | /** |
|
| 116 | * Get maximal retention obligation as a timestamp |
|