| Conditions | 10 |
| Paths | 6 |
| Total Lines | 25 |
| Code Lines | 15 |
| 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 |
||
| 73 | public static function signRequest($ikey, $skey, $akey, $username, $time = null) |
||
| 74 | { |
||
| 75 | if (!isset($username) || strlen($username) === 0) { |
||
| 76 | return self::ERR_USER; |
||
| 77 | } |
||
| 78 | if (strpos($username, '|') !== false) { |
||
| 79 | return self::ERR_USER; |
||
| 80 | } |
||
| 81 | if (!isset($ikey) || strlen($ikey) !== self::IKEY_LEN) { |
||
| 82 | return self::ERR_IKEY; |
||
| 83 | } |
||
| 84 | if (!isset($skey) || strlen($skey) !== self::SKEY_LEN) { |
||
| 85 | return self::ERR_SKEY; |
||
| 86 | } |
||
| 87 | if (!isset($akey) || strlen($akey) < self::AKEY_LEN) { |
||
| 88 | return self::ERR_AKEY; |
||
| 89 | } |
||
| 90 | |||
| 91 | $vals = $username . '|' . $ikey; |
||
| 92 | |||
| 93 | $duo_sig = self::signVals($skey, $vals, self::DUO_PREFIX, self::DUO_EXPIRE, $time); |
||
| 94 | $app_sig = self::signVals($akey, $vals, self::APP_PREFIX, self::APP_EXPIRE, $time); |
||
| 95 | |||
| 96 | return $duo_sig . ':' . $app_sig; |
||
| 97 | } |
||
| 98 | |||
| 113 |