| Conditions | 4 |
| Paths | 8 |
| Total Lines | 68 |
| Code Lines | 47 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 2 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 72 | public function getCMSFields() { |
||
| 73 | $fields = parent::getCMSFields(); |
||
| 74 | $fields->removeFieldFromTab('Root', 'Pages'); |
||
| 75 | $fields->removeFieldsFromTab('Root.Main', array( |
||
| 76 | 'SortOrder', |
||
| 77 | 'showBlockbyClass', |
||
| 78 | 'shownInClass', |
||
| 79 | 'MemberVisibility' |
||
| 80 | )); |
||
| 81 | |||
| 82 | $memberGroups = Group::get(); |
||
| 83 | $sourcemap = $memberGroups->map('Code', 'Title'); |
||
| 84 | $source = array( |
||
| 85 | 'anonymous' => 'Anonymous visitors' |
||
| 86 | ); |
||
| 87 | foreach ($sourcemap as $mapping => $key) { |
||
| 88 | $source[$mapping] = $key; |
||
| 89 | } |
||
| 90 | |||
| 91 | $memberVisibility = new CheckboxSetField( |
||
| 92 | $name = "MemberVisibility", |
||
| 93 | $title = "Show block for specific groups", |
||
| 94 | $source |
||
| 95 | ); |
||
| 96 | |||
| 97 | $memberVisibility->setDescription('Show this block only for the selected group(s). If you select no groups, the block will be visible to all members.'); |
||
| 98 | |||
| 99 | $availabelClasses = $this->availableClasses(); |
||
| 100 | $inClass = new CheckboxSetField( |
||
| 101 | $name = "shownInClass", |
||
| 102 | $title = "Show block for specific content types", |
||
| 103 | $availabelClasses |
||
| 104 | ); |
||
| 105 | |||
| 106 | $filterSelector = OptionsetField::create( |
||
| 107 | 'showBlockbyClass', |
||
| 108 | 'Choose filter set', |
||
| 109 | array( |
||
| 110 | '0' => 'by page', |
||
| 111 | '1' => 'by page/data type' |
||
| 112 | ) |
||
| 113 | )->setDescription('<p><br /><strong>by page</strong>: block will be displayed in the selected page(s)<br /><strong>by page/data type</strong>: block will be displayed on the pages created with the particular page/data type. e.g. is <strong>"InternalPage"</strong> is picked, the block will be displayed, and will ONLY be displayed on all <strong>Internal Pages</strong></p>'); |
||
| 114 | |||
| 115 | $availablePages = Page::get()->exclude('ClassName', array( |
||
| 116 | 'ErrorPage', |
||
| 117 | 'RedirectorPage', |
||
| 118 | 'VirtualPage' |
||
| 119 | )); |
||
| 120 | $pageSelector = new CheckboxSetField( |
||
| 121 | $name = "Pages", |
||
| 122 | $title = "Show on Page(s)", |
||
| 123 | $availablePages |
||
| 124 | ); |
||
| 125 | |||
| 126 | |||
| 127 | if ($this->canConfigPageAndType(Member::currentUser())) { |
||
|
1 ignored issue
–
show
|
|||
| 128 | $fields->addFieldsToTab('Root.VisibilitySettings', array( |
||
| 129 | $filterSelector, |
||
| 130 | $pageSelector, |
||
| 131 | $inClass |
||
| 132 | )); |
||
| 133 | } |
||
| 134 | |||
| 135 | if ($this->canConfigMemberVisibility(Member::currentUser())) { |
||
|
1 ignored issue
–
show
|
|||
| 136 | $fields->addFieldToTab('Root.VisibilitySettings', $memberVisibility); |
||
| 137 | } |
||
| 138 | return $fields; |
||
| 139 | } |
||
| 140 | |||
| 192 | } |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.