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