FAQFolder::getCMSFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
/**
3
 * Defines the FAQFolder page type - initial code created by ss generator
4
 */
5
class FAQFolder extends Page implements RenderableAsPortlet {
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...
6
7
	static $allowed_children = array( 'FAQFolder', 'FAQ' );
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $allowed_children.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
8
9
	static $has_one = array(
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $has_one.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
10
		'MainImage' => 'Image'
11
	);
12
13
	function getCMSFields() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
14
		$fields = parent::getCMSFields();
15
16
		$fields->addFieldToTab( 'Root.Content.Image', new ImageField( 'MainImage' ) );
17
18
19
		return $fields;
20
	}
21
22
23
	public function getPortletTitle() {
24
    return $this->Title;
25
  }  
26
27
28
  // FIXME - make this more efficient
29
  public function getPortletImage() {
30
  	if ($this->MainImageID) {
31
    return DataObject::get_by_id('Image', $this->MainImageID);
32
33
  	} else {
34
  		return null;
35
  	}
36
    
37
  }
38
  
39
  
40
 
41
  public function getPortletCaption() {
42
    return '';
43
  }
44
45
}
46
47
class FAQFolder_Controller extends Page_Controller {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
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...
48
49
}
50
51
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
52