GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Email::visit()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
cc 3
nc 3
nop 2
1
<?php
2
3
namespace Netgen\InformationCollection\Core\Persistence\Anonymizer\Visitor\Field;
4
5
use eZ\Publish\API\Repository\Values\ContentType\ContentType;
6
use Netgen\InformationCollection\API\Persistence\Anonymizer\Visitor\FieldAnonymizerVisitor;
7
use Netgen\InformationCollection\API\Value\Attribute;
8
use Netgen\InformationCollection\API\Value\AttributeValue;
9
10
class Email extends FieldAnonymizerVisitor
11
{
12
    protected $allowedCharacters = ['.', '@', '-', '+'];
13
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function accept(Attribute $attribute, ContentType $contentType): bool
18
    {
19
        return 'ezemail' === $attribute->getFieldDefinition()->fieldTypeIdentifier;
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function visit(Attribute $attribute, ContentType $contentType): AttributeValue
26
    {
27
        $email = $attribute->getValue()->getDataText();
28
29
        $split = str_split($email);
30
31
        $email = [];
32
        foreach ($split as $character) {
33
            if (!in_array($character, $this->allowedCharacters)) {
34
                $email[] = 'X';
35
            } else {
36
                $email[] = $character;
37
            }
38
        }
39
40
        return new AttributeValue(0, 0, implode($email, ''));
41
    }
42
}
43