Gravatar   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
lcom 2
cbo 1
dl 0
loc 41
ccs 0
cts 23
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setEmailHash() 0 4 1
A getEmailHash() 0 8 2
A hashEmail() 0 6 2
A run() 0 8 2
1
<?php
2
/**
3
 * HiPanel core package
4
 *
5
 * @link      https://hipanel.com/
6
 * @package   hipanel-core
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2014-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\widgets;
12
13
class Gravatar extends \cebe\gravatar\Gravatar
14
{
15
    public $defaultImage = 'identicon';
16
17
    public $rating = 'pg';
18
19
    protected $_emailHash;
20
21
    public function setEmailHash($hash)
22
    {
23
        $this->_emailHash = $hash;
24
    }
25
26
    /**
27
     * @return string
28
     */
29
    public function getEmailHash()
30
    {
31
        if (!$this->_emailHash) {
32
            $this->_emailHash = self::hashEmail($this->email);
33
        }
34
35
        return $this->_emailHash;
36
    }
37
38
    public static function hashEmail($email)
39
    {
40
        $email = strtolower(trim($email));
41
42
        return strpos($email, '@') === false ? $email : md5($email);
43
    }
44
45
    public function run()
46
    {
47
        if (!$this->emailHash) {
0 ignored issues
show
Bug introduced by
The property emailHash does not seem to exist. Did you mean _emailHash?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
48
            $this->defaultImage = '';
49
        }
50
51
        return parent::run();
52
    }
53
}
54