| Conditions | 9 |
| Paths | 14 |
| Total Lines | 53 |
| 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 namespace Comodojo\Cookies; |
||
| 46 | public static function setCookieProperties(CookieInterface $cookie, array $properties, $serialize) {
|
||
| 47 | |||
| 48 | try {
|
||
| 49 | |||
| 50 | foreach ( $properties as $property => $value ) {
|
||
| 51 | |||
| 52 | switch ( $property ) {
|
||
| 53 | |||
| 54 | case 'value': |
||
| 55 | |||
| 56 | $cookie->setValue($value, $serialize); |
||
| 57 | |||
| 58 | break; |
||
| 59 | |||
| 60 | case 'expire': |
||
| 61 | |||
| 62 | $cookie->setExpire($value); |
||
| 63 | |||
| 64 | break; |
||
| 65 | |||
| 66 | case 'path': |
||
| 67 | |||
| 68 | $cookie->setPath($value); |
||
| 69 | |||
| 70 | break; |
||
| 71 | |||
| 72 | case 'domain': |
||
| 73 | |||
| 74 | $cookie->setDomain($value); |
||
| 75 | |||
| 76 | break; |
||
| 77 | |||
| 78 | case 'secure': |
||
| 79 | |||
| 80 | $cookie->setSecure($value); |
||
| 81 | |||
| 82 | break; |
||
| 83 | |||
| 84 | case 'httponly': |
||
| 85 | |||
| 86 | $cookie->setHttponly($value); |
||
| 87 | |||
| 88 | break; |
||
| 89 | |||
| 90 | } |
||
| 91 | |||
| 92 | } |
||
| 93 | |||
| 94 | } catch (Exception $e) {
|
||
| 95 | throw $e; |
||
| 96 | } |
||
| 97 | |||
| 98 | return $cookie; |
||
| 99 | |||
| 123 |