| Conditions | 8 |
| Paths | 7 |
| Total Lines | 66 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 29 | public function update($event, $entryid, $props) |
||
| 30 | { |
||
| 31 | switch ($event) { |
||
| 32 | case TABLE_SAVE: |
||
| 33 | $data = array(); |
||
| 34 | |||
| 35 | if (isset($props[PR_STORE_ENTRYID])) { |
||
| 36 | $store = $GLOBALS["mapisession"]->openMessageStore($props[PR_STORE_ENTRYID]); |
||
| 37 | $properties = $this->getPropertiesList(); |
||
| 38 | |||
| 39 | $message = null; |
||
| 40 | if (isset($props[PR_ENTRYID])) { |
||
| 41 | $message = $GLOBALS["operations"]->openMessage($store, $props[PR_ENTRYID]); |
||
| 42 | $messageProps = mapi_getprops($message, $properties); |
||
| 43 | } else { |
||
| 44 | $messageProps = array(); |
||
| 45 | } |
||
| 46 | |||
| 47 | if (!isset($props[PR_ENTRYID]) || (isset($messageProps[$properties['recurring']]) && $messageProps[$properties['recurring']])) { |
||
| 48 | |||
| 49 | // An object was created inside this folder for which we don't know the entryid |
||
| 50 | // this can happen when we copy or move a message. Just tell the javascript that |
||
| 51 | // this folder has a new object. |
||
| 52 | // Alternatively the recurrence could have been changed, this means that we should send a notification to the client |
||
| 53 | // to inform the possibility that a different number of occurrences might be inside his view now. |
||
| 54 | $folder = mapi_msgstore_openentry($store, $props[PR_PARENT_ENTRYID]); |
||
| 55 | $folderProps = mapi_getprops($folder, array(PR_ENTRYID, PR_PARENT_ENTRYID, PR_STORE_ENTRYID, PR_CONTENT_COUNT, PR_CONTENT_UNREAD, PR_DISPLAY_NAME)); |
||
| 56 | |||
| 57 | $data = array( |
||
| 58 | "item" => array( |
||
| 59 | array( |
||
| 60 | "content_count" => $folderProps[PR_CONTENT_COUNT], |
||
| 61 | "content_unread" => $folderProps[PR_CONTENT_UNREAD], |
||
| 62 | // Add store_entryid,entryid of folder and display_name of folder |
||
| 63 | // to JSON data in order to refresh the list. |
||
| 64 | "store_entryid" => bin2hex($folderProps[PR_STORE_ENTRYID]), |
||
| 65 | "parent_entryid" => bin2hex($folderProps[PR_PARENT_ENTRYID]), |
||
| 66 | "entryid" => bin2hex($folderProps[PR_ENTRYID]), |
||
| 67 | "display_name" => $folderProps[PR_DISPLAY_NAME] |
||
| 68 | ) |
||
| 69 | ) |
||
| 70 | ); |
||
| 71 | |||
| 72 | $this->addNotificationActionData("newobject", $data); |
||
| 73 | } else { |
||
| 74 | $data = $GLOBALS["operations"]->getMessageProps($store, $message, $properties); |
||
| 75 | /** |
||
| 76 | * We dose't need these properties in AppointmentListNotifier, |
||
| 77 | * because if we send this properties in AppointmentListNotifier |
||
| 78 | * webapp use this properties and try to re-draw appointment in calendar |
||
| 79 | * which look annoying when user drag and drop same appointment frequently |
||
| 80 | * in calendar (related to WA-8897). |
||
| 81 | */ |
||
| 82 | unset($data['props']['startdate']); |
||
| 83 | unset($data['props']['duedate']); |
||
| 84 | unset($data['props']['commonstart']); |
||
| 85 | unset($data['props']['commonend']); |
||
| 86 | $this->addNotificationActionData("update", array( "item" => array($data))); |
||
| 87 | } |
||
| 88 | |||
| 89 | $GLOBALS["bus"]->addData($this->createNotificationResponseData()); |
||
| 90 | } |
||
| 91 | break; |
||
| 92 | case TABLE_DELETE: |
||
| 93 | parent::update($event, $entryid, $props); |
||
| 94 | break; |
||
| 95 | } |
||
| 100 |
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.