| Conditions | 6 |
| Paths | 24 |
| Total Lines | 21 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 6.288 |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | function gravatar($email, $connection = 'default', $size = null) |
||
| 14 | { |
||
| 15 | 1 | $hash = strlen($email) == 32 && ctype_xdigit($email) |
|
| 16 | ? strtolower($email) |
||
| 17 | 1 | : md5(strtolower(trim($email))); |
|
| 18 | |||
| 19 | 1 | if (is_int($connection)) { |
|
| 20 | list($connection, $size) = [ |
||
| 21 | is_string($size) ? $size : 'default', $connection, |
||
| 22 | ]; |
||
| 23 | } |
||
| 24 | |||
| 25 | 1 | $config = array_filter(array_merge( |
|
| 26 | 1 | config('gravatar.'.$connection, []), compact('size') |
|
| 27 | )); |
||
| 28 | |||
| 29 | 1 | $url = array_pull($config, 'url', 'https://secure.gravatar.com/avatar'); |
|
| 30 | 1 | $query = http_build_query($config); |
|
| 31 | |||
| 32 | 1 | return $url.'/'.$hash.($query ? '?'.$query : ''); |
|
| 33 | } |
||
| 34 | } |
||
| 35 |