Completed
Push — master ( 78f4d4...47ceaa )
by Michiel
02:25 queued 51s
created

Profile   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 69
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromData() 14 14 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * Copyright 2019 SURFnet B.V.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace Surfnet\StepupMiddlewareClientBundle\Identity\Dto;
20
21
use Surfnet\StepupMiddlewareClientBundle\Dto\Dto;
22
use Symfony\Component\Validator\Constraints as Assert;
23
24 View Code Duplication
class Profile implements Dto
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
{
26
    /**
27
     * @Assert\NotBlank(message="middleware_client.dto.identity.id.must_not_be_blank")
28
     * @Assert\Type(type="string", message="middleware_client.dto.identity.id.must_be_string")
29
     * @var string
30
     */
31
    public $id;
32
33
    /**
34
     * @Assert\NotBlank(message="middleware_client.dto.identity.name_id.must_not_be_blank")
35
     * @Assert\Type(type="string", message="middleware_client.dto.identity.name_id.must_be_string")
36
     * @var string
37
     */
38
    public $nameId;
39
40
    /**
41
     * @Assert\NotBlank(message="middleware_client.dto.identity.institution.must_not_be_blank")
42
     * @Assert\Type(type="string", message="middleware_client.dto.identity.institution.must_be_string")
43
     * @var string
44
     */
45
    public $institution;
46
47
    /**
48
     * @Assert\NotBlank(message="middleware_client.dto.identity.email.must_not_be_blank")
49
     * @Assert\Type(type="string", message="middleware_client.dto.identity.email.must_be_string")
50
     * @var string
51
     */
52
    public $email;
53
54
    /**
55
     * @Assert\NotBlank(message="middleware_client.dto.identity.common_name.must_not_be_blank")
56
     * @Assert\Type(type="string", message="middleware_client.dto.identity.common_name.must_be_string")
57
     * @var string
58
     */
59
    public $commonName;
60
61
    /**
62
     * @Assert\NotBlank(message="middleware_client.dto.identity.preferred_locale.must_not_be_blank")
63
     * @Assert\Type(type="string", message="middleware_client.dto.identity.preferred_locale.must_be_string")
64
     * @var string
65
     */
66
    public $preferredLocale;
67
68
    /**
69
     * @var bool
70
     */
71
    public $isSraa;
72
73
    /**
74
     * @var array
75
     */
76
    public $authorizations;
77
78
    public static function fromData(array $data)
79
    {
80
        $identity = new self();
81
        $identity->id = $data['id'];
82
        $identity->nameId = $data['name_id'];
83
        $identity->institution = $data['institution'];
84
        $identity->email = $data['email'];
85
        $identity->commonName = $data['common_name'];
86
        $identity->preferredLocale = $data['preferred_locale'];
87
        $identity->authorizations = $data['authorizations'];
88
        $identity->isSraa = $data['is_sraa'];
89
90
        return $identity;
91
    }
92
}
93