Code Duplication    Length = 36-36 lines in 2 locations

apps/files_trashbin/lib/expiration.php 1 location

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

apps/files_versions/lib/expiration.php 1 location

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