| Conditions | 13 |
| Paths | 256 |
| Total Lines | 101 |
| Code Lines | 54 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
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 |
||
| 55 | public function createReminderFolder($store) { |
||
| 56 | $storeProps = mapi_getprops($store, [PR_IPM_OUTBOX_ENTRYID, PR_IPM_WASTEBASKET_ENTRYID, PR_IPM_SUBTREE_ENTRYID]); |
||
| 57 | $root = mapi_msgstore_openentry($store, null); |
||
| 58 | $rootProps = mapi_getprops($root, [PR_ADDITIONAL_REN_ENTRYIDS, PR_IPM_DRAFTS_ENTRYID]); |
||
| 59 | |||
| 60 | $folders = []; |
||
| 61 | if (isset($storeProps[PR_IPM_WASTEBASKET_ENTRYID])) { |
||
| 62 | $folders[] = $storeProps[PR_IPM_WASTEBASKET_ENTRYID]; |
||
| 63 | } |
||
| 64 | if (isset($rootProps[PR_ADDITIONAL_REN_ENTRYIDS]) && !empty($rootProps[PR_ADDITIONAL_REN_ENTRYIDS][4])) { |
||
| 65 | $folders[] = $rootProps[PR_ADDITIONAL_REN_ENTRYIDS][4]; |
||
| 66 | } // junk mail |
||
| 67 | if (isset($rootProps[PR_IPM_DRAFTS_ENTRYID])) { |
||
| 68 | $folders[] = $rootProps[PR_IPM_DRAFTS_ENTRYID]; |
||
| 69 | } |
||
| 70 | if (isset($storeProps[PR_IPM_OUTBOX_ENTRYID])) { |
||
| 71 | $folders[] = $storeProps[PR_IPM_OUTBOX_ENTRYID]; |
||
| 72 | } |
||
| 73 | if (isset($rootProps[PR_ADDITIONAL_REN_ENTRYIDS]) && !empty($rootProps[PR_ADDITIONAL_REN_ENTRYIDS][0])) { |
||
| 74 | $folders[] = $rootProps[PR_ADDITIONAL_REN_ENTRYIDS][0]; |
||
| 75 | } // conflicts |
||
| 76 | if (isset($rootProps[PR_ADDITIONAL_REN_ENTRYIDS]) && !empty($rootProps[PR_ADDITIONAL_REN_ENTRYIDS][2])) { |
||
| 77 | $folders[] = $rootProps[PR_ADDITIONAL_REN_ENTRYIDS][2]; |
||
| 78 | } // local failures |
||
| 79 | if (isset($rootProps[PR_ADDITIONAL_REN_ENTRYIDS]) && !empty($rootProps[PR_ADDITIONAL_REN_ENTRYIDS][1])) { |
||
| 80 | $folders[] = $rootProps[PR_ADDITIONAL_REN_ENTRYIDS][1]; |
||
| 81 | } // sync issues |
||
| 82 | |||
| 83 | $folderRestriction = []; |
||
| 84 | foreach ($folders as $folder) { |
||
| 85 | $folderRestriction[] = [RES_PROPERTY, |
||
| 86 | [ |
||
| 87 | RELOP => RELOP_NE, |
||
| 88 | ULPROPTAG => $this->properties["parent_entryid"], |
||
| 89 | VALUE => [$this->properties["parent_entryid"] => $folder], |
||
| 90 | ], |
||
| 91 | ]; |
||
| 92 | } |
||
| 93 | |||
| 94 | $res = |
||
| 95 | [RES_AND, |
||
| 96 | [ |
||
| 97 | [RES_AND, |
||
| 98 | $folderRestriction, |
||
| 99 | ], |
||
| 100 | [RES_AND, |
||
| 101 | [ |
||
| 102 | [RES_NOT, |
||
| 103 | [ |
||
| 104 | [RES_AND, |
||
| 105 | [ |
||
| 106 | [RES_EXIST, |
||
| 107 | [ |
||
| 108 | ULPROPTAG => $this->properties["message_class"], |
||
| 109 | ], |
||
| 110 | ], |
||
| 111 | [RES_CONTENT, |
||
| 112 | [ |
||
| 113 | FUZZYLEVEL => FL_PREFIX, |
||
| 114 | ULPROPTAG => $this->properties["message_class"], |
||
| 115 | VALUE => [$this->properties["message_class"] => "IPM.Schedule"], |
||
| 116 | ], |
||
| 117 | ], |
||
| 118 | ], |
||
| 119 | ], |
||
| 120 | ], |
||
| 121 | ], |
||
| 122 | [RES_BITMASK, |
||
| 123 | [ |
||
| 124 | ULTYPE => BMR_EQZ, |
||
| 125 | ULPROPTAG => $this->properties["message_flags"], |
||
| 126 | ULMASK => MSGFLAG_SUBMIT, |
||
| 127 | ], |
||
| 128 | ], |
||
| 129 | [RES_OR, |
||
| 130 | [ |
||
| 131 | [RES_PROPERTY, |
||
| 132 | [ |
||
| 133 | RELOP => RELOP_EQ, |
||
| 134 | ULPROPTAG => $this->properties["reminder"], |
||
| 135 | VALUE => [$this->properties["reminder"] => true], |
||
| 136 | ], |
||
| 137 | ], |
||
| 138 | ], |
||
| 139 | ], |
||
| 140 | ], |
||
| 141 | ], |
||
| 142 | ], |
||
| 143 | ]; |
||
| 144 | |||
| 145 | $folder = mapi_folder_createfolder($root, _("Reminders"), "", OPEN_IF_EXISTS, FOLDER_SEARCH); |
||
| 146 | mapi_setprops($folder, [PR_CONTAINER_CLASS => "Outlook.Reminder"]); |
||
| 147 | mapi_savechanges($folder); |
||
| 148 | |||
| 149 | mapi_folder_setsearchcriteria($folder, $res, [$storeProps[PR_IPM_SUBTREE_ENTRYID]], RECURSIVE_SEARCH); |
||
| 150 | $folderProps = mapi_getprops($folder, [PR_ENTRYID]); |
||
| 151 | |||
| 152 | mapi_setprops($root, [PR_REM_ONLINE_ENTRYID => $folderProps[PR_ENTRYID]]); |
||
| 153 | mapi_savechanges($root); |
||
| 154 | |||
| 155 | return $folderProps[PR_ENTRYID]; |
||
| 156 | } |
||
| 293 |