Test Failed
Push — master ( 10865e...d038e5 )
by Simon
10:06
created

GravatarModel   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 32
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getGravatar() 0 14 3
1
<?php
2
3
namespace Schanihbg\Gravatar;
4
5
use \Anax\DI\InjectionAwareInterface;
6
use \Anax\DI\InjectionAwareTrait;
7
use \Anax\Configure\ConfigureInterface;
8
use \Anax\Configure\ConfigureTrait;
9
10
/**
11
 * Gravatar.
12
 */
13
class GravatarModel implements ConfigureInterface, InjectionAwareInterface
14
{
15
    use ConfigureTrait;
16
    use InjectionAwareTrait;
17
18
    /**
19
     * Get either a Gravatar URL or complete image tag for a specified email address.
20
     *
21
     * @param string $email The email address
22
     * @param string $size Size in pixels, defaults to 80px [ 1 - 2048 ]
23
     * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
0 ignored issues
show
Bug introduced by
There is no parameter named $d. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
24
     * @param string $rating Maximum rating (inclusive) [ g | pg | r | x ]
25
     * @param boole $img True to return a complete IMG tag False for just the URL
26
     * @param array $atts Optional, additional key/value attributes to include in the IMG tag
27
     * @return String containing either just a URL or a complete image tag
28
     * @source https://gravatar.com/site/implement/images/php/
29
     */
30
    public function getGravatar($email, $size, $dImageset, $rating, $img, $atts)
31
    {
32
        $url = 'https://www.gravatar.com/avatar/';
33
        $url .= md5(strtolower(trim($email)));
34
        $url .= "?s=$size&d=$dImageset&r=$rating";
35
        if ($img) {
36
            $url = '<img src="' . $url . '"';
37
            foreach ($atts as $key => $val) {
38
                $url .= ' ' . $key . '="' . $val . '"';
39
            }
40
            $url .= ' />';
41
        }
42
        return $url;
43
    }
44
}
45