| Conditions | 10 |
| Paths | 10 |
| Total Lines | 115 |
| Code Lines | 89 |
| 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 |
||
| 45 | public function shared(array $params) { |
||
| 46 | if ($params['shareType'] === IShare::TYPE_LINK) { |
||
| 47 | $this->log( |
||
| 48 | 'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)', |
||
| 49 | $params, |
||
| 50 | [ |
||
| 51 | 'itemType', |
||
| 52 | 'itemTarget', |
||
| 53 | 'itemSource', |
||
| 54 | 'permissions', |
||
| 55 | 'id', |
||
| 56 | ] |
||
| 57 | ); |
||
| 58 | } elseif ($params['shareType'] === IShare::TYPE_USER) { |
||
| 59 | $this->log( |
||
| 60 | 'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)', |
||
| 61 | $params, |
||
| 62 | [ |
||
| 63 | 'itemType', |
||
| 64 | 'itemTarget', |
||
| 65 | 'itemSource', |
||
| 66 | 'shareWith', |
||
| 67 | 'permissions', |
||
| 68 | 'id', |
||
| 69 | ] |
||
| 70 | ); |
||
| 71 | } elseif ($params['shareType'] === IShare::TYPE_GROUP) { |
||
| 72 | $this->log( |
||
| 73 | 'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)', |
||
| 74 | $params, |
||
| 75 | [ |
||
| 76 | 'itemType', |
||
| 77 | 'itemTarget', |
||
| 78 | 'itemSource', |
||
| 79 | 'shareWith', |
||
| 80 | 'permissions', |
||
| 81 | 'id', |
||
| 82 | ] |
||
| 83 | ); |
||
| 84 | } elseif ($params['shareType'] === IShare::TYPE_ROOM) { |
||
| 85 | $this->log( |
||
| 86 | 'The %s "%s" with ID "%s" has been shared to the room "%s" with permissions "%s" (Share ID: %s)', |
||
| 87 | $params, |
||
| 88 | [ |
||
| 89 | 'itemType', |
||
| 90 | 'itemTarget', |
||
| 91 | 'itemSource', |
||
| 92 | 'shareWith', |
||
| 93 | 'permissions', |
||
| 94 | 'id', |
||
| 95 | ] |
||
| 96 | ); |
||
| 97 | } elseif ($params['shareType'] === IShare::TYPE_EMAIL) { |
||
| 98 | $this->log( |
||
| 99 | 'The %s "%s" with ID "%s" has been shared to the email recipient "%s" with permissions "%s" (Share ID: %s)', |
||
| 100 | $params, |
||
| 101 | [ |
||
| 102 | 'itemType', |
||
| 103 | 'itemTarget', |
||
| 104 | 'itemSource', |
||
| 105 | 'shareWith', |
||
| 106 | 'permissions', |
||
| 107 | 'id', |
||
| 108 | ] |
||
| 109 | ); |
||
| 110 | } elseif ($params['shareType'] === IShare::TYPE_CIRCLE) { |
||
| 111 | $this->log( |
||
| 112 | 'The %s "%s" with ID "%s" has been shared to the circle "%s" with permissions "%s" (Share ID: %s)', |
||
| 113 | $params, |
||
| 114 | [ |
||
| 115 | 'itemType', |
||
| 116 | 'itemTarget', |
||
| 117 | 'itemSource', |
||
| 118 | 'shareWith', |
||
| 119 | 'permissions', |
||
| 120 | 'id', |
||
| 121 | ] |
||
| 122 | ); |
||
| 123 | } elseif ($params['shareType'] === IShare::TYPE_REMOTE) { |
||
| 124 | $this->log( |
||
| 125 | 'The %s "%s" with ID "%s" has been shared to the remote user "%s" with permissions "%s" (Share ID: %s)', |
||
| 126 | $params, |
||
| 127 | [ |
||
| 128 | 'itemType', |
||
| 129 | 'itemTarget', |
||
| 130 | 'itemSource', |
||
| 131 | 'shareWith', |
||
| 132 | 'permissions', |
||
| 133 | 'id', |
||
| 134 | ] |
||
| 135 | ); |
||
| 136 | } elseif ($params['shareType'] === IShare::TYPE_REMOTE_GROUP) { |
||
| 137 | $this->log( |
||
| 138 | 'The %s "%s" with ID "%s" has been shared to the remote group "%s" with permissions "%s" (Share ID: %s)', |
||
| 139 | $params, |
||
| 140 | [ |
||
| 141 | 'itemType', |
||
| 142 | 'itemTarget', |
||
| 143 | 'itemSource', |
||
| 144 | 'shareWith', |
||
| 145 | 'permissions', |
||
| 146 | 'id', |
||
| 147 | ] |
||
| 148 | ); |
||
| 149 | } elseif ($params['shareType'] === IShare::TYPE_DECK) { |
||
| 150 | $this->log( |
||
| 151 | 'The %s "%s" with ID "%s" has been shared to the deck card "%s" with permissions "%s" (Share ID: %s)', |
||
| 152 | $params, |
||
| 153 | [ |
||
| 154 | 'itemType', |
||
| 155 | 'itemTarget', |
||
| 156 | 'itemSource', |
||
| 157 | 'shareWith', |
||
| 158 | 'permissions', |
||
| 159 | 'id', |
||
| 160 | ] |
||
| 350 |