Completed
Push — master ( 98b2f1...a418ff )
by Dimas
08:55
created

get_gravatar()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 9
c 1
b 0
f 0
nc 2
nop 6
dl 0
loc 12
rs 9.9666
1
<?php
2
3
/**
4
 * Get either a Gravatar URL or complete image tag for a specified email address.
5
 *
6
 * @param string $email The email address
7
 * @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ]
8
 * @param string $d Default imageset to use [ 404 | mp | identicon | monsterid | wavatar ]
9
 * @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
10
 * @param boole $img True to return a complete IMG tag False for just the URL
0 ignored issues
show
Bug introduced by
The type boole was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
 * @param array $atts Optional, additional key/value attributes to include in the IMG tag
12
 * @return String containing either just a URL or a complete image tag
13
 * @source https://gravatar.com/site/implement/images/php/
14
 */
15
function get_gravatar($email, $s = 80, $d = 'mp', $r = 'g', $img = false, $atts = array())
16
{
17
    $url = 'https://www.gravatar.com/avatar/';
18
    $url .= md5(strtolower(trim($email)));
19
    $url .= "?s=$s&d=$d&r=$r";
20
    if ($img) {
21
        $url = '<img src="' . $url . '"';
22
        foreach ($atts as $key => $val)
23
            $url .= ' ' . $key . '="' . $val . '"';
24
        $url .= ' />';
25
    }
26
    return $url;
27
}
28