Conditions | 15 |
Paths | 512 |
Total Lines | 121 |
Code Lines | 63 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 1 | Features | 1 |
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 |
||
51 | public function createReminderFolder($store) { |
||
52 | $storeProps = mapi_getprops($store, [PR_IPM_OUTBOX_ENTRYID, PR_IPM_WASTEBASKET_ENTRYID, PR_IPM_SUBTREE_ENTRYID]); |
||
53 | $root = mapi_msgstore_openentry($store); |
||
54 | $rootProps = mapi_getprops($root, [PR_ADDITIONAL_REN_ENTRYIDS, PR_IPM_DRAFTS_ENTRYID]); |
||
55 | |||
56 | $folders = []; |
||
57 | /* The list of forbidden folders (MS-OXORMDR v14 §1.1) */ |
||
58 | if (isset($storeProps[PR_IPM_WASTEBASKET_ENTRYID])) { |
||
59 | $folders[] = $storeProps[PR_IPM_WASTEBASKET_ENTRYID]; |
||
60 | } |
||
61 | if (isset($rootProps[PR_ADDITIONAL_REN_ENTRYIDS]) && !empty($rootProps[PR_ADDITIONAL_REN_ENTRYIDS][4])) { |
||
62 | $folders[] = $rootProps[PR_ADDITIONAL_REN_ENTRYIDS][4]; |
||
63 | } // junk mail |
||
64 | if (isset($rootProps[PR_IPM_DRAFTS_ENTRYID])) { |
||
65 | $folders[] = $rootProps[PR_IPM_DRAFTS_ENTRYID]; |
||
66 | } |
||
67 | if (isset($storeProps[PR_IPM_OUTBOX_ENTRYID])) { |
||
68 | $folders[] = $storeProps[PR_IPM_OUTBOX_ENTRYID]; |
||
69 | } |
||
70 | if (isset($rootProps[PR_ADDITIONAL_REN_ENTRYIDS]) && !empty($rootProps[PR_ADDITIONAL_REN_ENTRYIDS][0])) { |
||
71 | $folders[] = $rootProps[PR_ADDITIONAL_REN_ENTRYIDS][0]; |
||
72 | } // conflicts |
||
73 | if (isset($rootProps[PR_ADDITIONAL_REN_ENTRYIDS]) && !empty($rootProps[PR_ADDITIONAL_REN_ENTRYIDS][2])) { |
||
74 | $folders[] = $rootProps[PR_ADDITIONAL_REN_ENTRYIDS][2]; |
||
75 | } // local failures |
||
76 | if (isset($rootProps[PR_ADDITIONAL_REN_ENTRYIDS]) && !empty($rootProps[PR_ADDITIONAL_REN_ENTRYIDS][3])) { |
||
77 | $folders[] = $rootProps[PR_ADDITIONAL_REN_ENTRYIDS][3]; |
||
78 | } // server 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 | [RES_AND, |
||
139 | [ |
||
140 | [RES_EXIST, |
||
141 | [ |
||
142 | ULPROPTAG => $this->properties["recurring"], |
||
143 | ], |
||
144 | ], |
||
145 | [RES_PROPERTY, |
||
146 | [ |
||
147 | RELOP => RELOP_EQ, |
||
148 | ULPROPTAG => $this->properties["recurring"], |
||
149 | VALUE => [$this->properties["recurring"] => true], |
||
150 | ], |
||
151 | ], |
||
152 | ], |
||
153 | ], |
||
154 | ], |
||
155 | ], |
||
156 | ], |
||
157 | ], |
||
158 | ], |
||
159 | ]; |
||
160 | |||
161 | $folder = mapi_folder_createfolder($root, _("Reminders"), "", OPEN_IF_EXISTS, FOLDER_SEARCH); |
||
162 | mapi_setprops($folder, [PR_CONTAINER_CLASS => "Outlook.Reminder"]); |
||
163 | mapi_savechanges($folder); |
||
164 | |||
165 | mapi_folder_setsearchcriteria($folder, $res, [$storeProps[PR_IPM_SUBTREE_ENTRYID]], RECURSIVE_SEARCH); |
||
166 | $folderProps = mapi_getprops($folder, [PR_ENTRYID]); |
||
167 | |||
168 | mapi_setprops($root, [PR_REM_ONLINE_ENTRYID => $folderProps[PR_ENTRYID]]); |
||
169 | mapi_savechanges($root); |
||
170 | |||
171 | return $folderProps[PR_ENTRYID]; |
||
172 | } |
||
309 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.