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   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A accept() 0 4 1
A visit() 0 17 3
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