Code Duplication    Length = 27-27 lines in 2 locations

apps/files_trashbin/lib/expiration.php 1 location

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

apps/files_versions/lib/expiration.php 1 location

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