Code Duplication    Length = 27-27 lines in 2 locations

apps/files_trashbin/lib/expiration.php 1 location

@@ 138-164 (lines=27) @@
135
			$maxValue = trim($splitValues[1]);
136
		}
137
138
		if ($minValue === 'auto' && $maxValue === 'auto') {
139
			// Default: Keep for 30 days but delete anytime if space needed
140
			$this->minAge = self::DEFAULT_RETENTION_OBLIGATION;
141
			$this->maxAge = self::NO_OBLIGATION;
142
			$this->canPurgeToSaveSpace = true;
143
		} elseif ($minValue !== 'auto' && $maxValue === 'auto') {
144
			// Keep for X days but delete anytime if space needed
145
			$this->minAge = intval($minValue);
146
			$this->maxAge = self::NO_OBLIGATION;
147
			$this->canPurgeToSaveSpace = true;
148
		} elseif ($minValue === 'auto' && $maxValue !== 'auto') {
149
			// Delete anytime if space needed, Delete all older than max automatically
150
			$this->minAge = self::NO_OBLIGATION;
151
			$this->maxAge = intval($maxValue);
152
			$this->canPurgeToSaveSpace = true;
153
		} elseif ($minValue !== 'auto' && $maxValue !== 'auto') {
154
			// Delete all older than max OR older than min if space needed
155
156
			// Max < Min as per https://github.com/owncloud/core/issues/16300
157
			if ($maxValue < $minValue) {
158
				$maxValue = $minValue;
159
			}
160
161
			$this->minAge = intval($minValue);
162
			$this->maxAge = intval($maxValue);
163
			$this->canPurgeToSaveSpace = false;
164
		}
165
	}
166
}
167

apps/files_versions/lib/expiration.php 1 location

@@ 171-197 (lines=27) @@
168
		}
169
170
171
		if ($minValue === 'auto' && $maxValue === 'auto') {
172
			// Default: Delete anytime if space needed
173
			$this->minAge = self::NO_OBLIGATION;
174
			$this->maxAge = self::NO_OBLIGATION;
175
			$this->canPurgeToSaveSpace = true;
176
		} elseif ($minValue !== 'auto' && $maxValue === 'auto') {
177
			// Keep for X days but delete anytime if space needed
178
			$this->minAge = intval($minValue);
179
			$this->maxAge = self::NO_OBLIGATION;
180
			$this->canPurgeToSaveSpace = true;
181
		} elseif ($minValue === 'auto' && $maxValue !== 'auto') {
182
			// Delete anytime if space needed, Delete all older than max automatically
183
			$this->minAge = self::NO_OBLIGATION;
184
			$this->maxAge = intval($maxValue);
185
			$this->canPurgeToSaveSpace = true;
186
		} elseif ($minValue !== 'auto' && $maxValue !== 'auto') {
187
			// Delete all older than max OR older than min if space needed
188
189
			// Max < Min as per https://github.com/owncloud/core/issues/16301
190
			if ($maxValue < $minValue) {
191
				$maxValue = $minValue;
192
			}
193
194
			$this->minAge = intval($minValue);
195
			$this->maxAge = intval($maxValue);
196
			$this->canPurgeToSaveSpace = false;
197
		}
198
	}
199
}
200