Code Duplication    Length = 12-14 lines in 4 locations

tests/filesystem/AssetControlExtensionTest.php 1 location

@@ 224-237 (lines=14) @@
221
	 * @param Member $member
222
	 * @return bool
223
	 */
224
	public function canView($member = null) {
225
		if(!$member) {
226
			$member = Member::currentUser();
227
		}
228
229
		// Expectation that versioned::canView will hide this object in draft
230
		$result = $this->extendedCan('canView', $member);
231
		if($result !== null) {
232
			return $result;
233
		}
234
235
		// Open to public
236
		return true;
237
	}
238
}
239
240
/**

filesystem/File.php 3 locations

@@ 363-374 (lines=12) @@
360
	 * @param Member $member
361
	 * @return bool
362
	 */
363
	public function canView($member = null) {
364
		if(!$member) {
365
			$member = Member::currentUser();
366
		}
367
368
		$result = $this->extendedCan('canView', $member);
369
		if($result !== null) {
370
			return $result;
371
		}
372
373
		return true;
374
	}
375
376
	/**
377
	 * Check if this file can be modified
@@ 402-413 (lines=12) @@
399
	 * @param array $context
400
	 * @return boolean
401
	 */
402
	public function canCreate($member = null, $context = array()) {
403
		if(!$member) {
404
			$member = Member::currentUser();
405
		}
406
407
		$result = $this->extendedCan('canCreate', $member, $context);
408
		if($result !== null) {
409
			return $result;
410
		}
411
412
		return $this->canEdit($member);
413
	}
414
415
	/**
416
	 * Check if this file can be deleted
@@ 421-432 (lines=12) @@
418
	 * @param Member $member
419
	 * @return boolean
420
	 */
421
	public function canDelete($member = null) {
422
		if(!$member) {
423
			$member = Member::currentUser();
424
		}
425
426
		$result = $this->extendedCan('canDelete', $member);
427
		if($result !== null) {
428
			return $result;
429
		}
430
431
		return $this->canEdit($member);
432
	}
433
434
	/**
435
	 * Returns the fields to power the edit screen of files in the CMS.