AddImageExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 28
ccs 0
cts 11
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A updateCMSFields() 0 5 1
A getPortletTitle() 0 3 1
A getPortletImage() 0 3 1
A getPortletCaption() 0 3 1
1
<?php
2
3
class AddImageExtension extends DataExtension {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
	private static $has_one = array(
0 ignored issues
show
Unused Code introduced by
The property $has_one is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
5
		'MainImage' => 'Image'
6
	);
7
8
9
	/*
10
	Add a Location tab containing the map
11
	*/
12
	public function updateCMSFields(FieldList $fields) {
13
		$fields->addFieldToTab('Root.Image', $uf = new UploadField('MainImage',
14
			_t('PageWithImage.MAIN_IMAGE', 'Main Image')));
15
		$uf->setFolderName('pagewithimage');
16
	}
17
18
19
	public function getPortletTitle() {
20
		return $this->owner->Title;
21
	}
22
23
	public function getPortletImage() {
24
		return $this->owner->MainImage();
25
	}
26
27
	public function getPortletCaption() {
28
		return $this->owner->Title;
29
	}
30
}
31