UserInfos   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 22
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 20 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\View\Helper;
6
7
use Application\Model\User;
8
use Laminas\View\Helper\AbstractHelper;
9
10
class UserInfos extends AbstractHelper
11
{
12 7
    public function __invoke(?User $user): string
13
    {
14 7
        if (!$user) {
15 1
            return '<p>Utilisateur inconnu. Il a probablement été supprimé.</p>';
16
        }
17
18 6
        $url = $this->view->serverUrl . '/admin/user/' . $user->getId();
19
20 6
        $result = '<ul>';
21 6
        $result .= '<li>' . $this->view->escapeHtml($user->getFirstName()) . '</li>';
0 ignored issues
show
Bug introduced by
The method escapeHtml() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
        $result .= '<li>' . $this->view->/** @scrutinizer ignore-call */ escapeHtml($user->getFirstName()) . '</li>';

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
22 6
        $result .= '<li>' . $this->view->escapeHtml($user->getLastName()) . '</li>';
23 6
        $result .= '<li>' . $this->view->escapeHtml($user->getStreet()) . '</li>';
24 6
        $result .= '<li>' . $this->view->escapeHtml($user->getPostcode()) . '</li>';
25 6
        $result .= '<li>' . $this->view->escapeHtml($user->getLocality()) . '</li>';
26 6
        $result .= '<li>' . $this->view->escapeHtml($user->getCountry() ? $user->getCountry()->getName() : '') . '</li>';
27 6
        $result .= '<li><a href="mailto:' . $this->view->escapeHtmlAttr($user->getEmail()) . '">' . $this->view->escapeHtml($user->getEmail()) . '</a></li>';
28 6
        $result .= '<li><a href="' . $url . '">' . $this->view->escapeHtml($url) . '</a></li>';
29 6
        $result .= '</ul>';
30
31 6
        return $result;
32
    }
33
}
34