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.

InformationCollectionStruct   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 3
dl 0
loc 79
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A getLanguageCode() 0 4 1
A getContent() 0 4 1
A getContentType() 0 4 1
A getFieldsData() 0 4 1
A getCollectedFields() 0 4 1
A addFieldData() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Netgen\InformationCollection\API\Value;
6
7
use eZ\Publish\API\Repository\Values\Content\Content;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, Netgen\InformationCollection\API\Value\Content.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
8
use eZ\Publish\API\Repository\Values\ContentType\ContentType;
9
use EzSystems\RepositoryForms\Data\Content\FieldData;
10
11
final class InformationCollectionStruct extends ValueObject
12
{
13
    /**
14
     * The language code of the version.
15
     *
16
     * @var string
17
     */
18
    protected $languageCode;
19
20
    /**
21
     * @var \eZ\Publish\API\Repository\Values\Content\Content
22
     */
23
    protected $content;
24
25
    /**
26
     * @var \eZ\Publish\API\Repository\Values\ContentType\ContentType
27
     */
28
    protected $contentType;
29
30
    /**
31
     * @var \EzSystems\RepositoryForms\Data\Content\FieldData[]
32
     */
33
    protected $fields;
34
35
    public function __construct(Content $content, ContentType $contentType, array $fields)
36
    {
37
        $this->content = $content;
38
        $this->contentType = $contentType;
39
40
        foreach ($fields as $field) {
41
            $this->addFieldData($field);
42
        }
43
    }
44
45
    /**
46
     * @return string
47
     */
48
    public function getLanguageCode(): string
49
    {
50
        return $this->content->contentInfo->mainLanguageCode;
51
    }
52
53
    /**
54
     * @return \eZ\Publish\API\Repository\Values\Content\Content
55
     */
56
    public function getContent(): Content
57
    {
58
        return $this->content;
59
    }
60
61
    /**
62
     * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType
63
     */
64
    public function getContentType(): ContentType
65
    {
66
        return $this->contentType;
67
    }
68
69
    /**
70
     * @return \EzSystems\RepositoryForms\Data\Content\FieldData[]
71
     */
72
    public function getFieldsData(): array
73
    {
74
        return $this->fields;
75
    }
76
77
    /**
78
     * @return \EzSystems\RepositoryForms\Data\Content\FieldData[]
79
     */
80
    public function getCollectedFields(): array
81
    {
82
       return $this->fields;
83
    }
84
85
    protected function addFieldData(FieldData $fieldData)
86
    {
87
        $this->fields[$fieldData->fieldDefinition->identifier] = $fieldData;
88
    }
89
}
90