DeploynautFileExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A canDownload() 0 11 2
1
<?php
2
class DeploynautFileExtension extends DataExtension {
3
	/**
4
	 * If this file is attached to a {@link DNDataArchive}, then we need to check security permissions, to ensure the
5
	 * currently logged in {@link Member} can download the file.
6
	 *
7
	 * This uses the secureassets module to provide the security of these assets.
8
	 */
9
	public function canDownload() {
10
		$member = Member::currentUser();
11
		$file = $this->owner;
12
		$archive = DNDataArchive::get()->filter('ArchiveFileID', $file->ID)->First();
13
14
		if($archive) {
15
			return $archive->canDownload($member);
16
		}
17
18
		return true; // By default, files can be downloaded from assets/ normally
19
	}
20
}
21