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