RaLocation   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 28
dl 0
loc 63
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 8 1
A create() 0 16 1
1
<?php
2
3
/**
4
 * Copyright 2016 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\StepupMiddleware\ApiBundle\Configuration\Entity;
20
21
use Doctrine\ORM\Mapping as ORM;
22
use JsonSerializable;
23
use Surfnet\Stepup\Configuration\Value\ContactInformation;
24
use Surfnet\Stepup\Configuration\Value\Institution;
25
use Surfnet\Stepup\Configuration\Value\Location;
26
use Surfnet\Stepup\Configuration\Value\RaLocationName;
27
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\RaLocationRepository;
28
29
#[ORM\Table]
30
#[ORM\Index(name: 'idx_ra_location_institution', columns: ['institution'])]
31
#[ORM\Entity(repositoryClass: RaLocationRepository::class)]
32
class RaLocation implements JsonSerializable
33
{
34
    /**
35
     *
36
     * @var string
37
     */
38
    #[ORM\Id]
39
    #[ORM\Column(length: 36)]
40
    public string $id;
41
42
    /**
43
     * @var Institution
44
     */
45
    #[ORM\Column(type: 'stepup_configuration_institution')]
46
    public Institution $institution;
47
48
    /**
49
     * @var RaLocationName
50
     */
51
    #[ORM\Column(type: 'stepup_ra_location_name')]
52
    public RaLocationName $name;
53
54
    /**
55
     * @var Location
56
     */
57
    #[ORM\Column(type: 'stepup_configuration_location')]
58
    public Location $location;
59
60
    /**
61
     * @var ContactInformation
62
     */
63
    #[ORM\Column(type: 'stepup_configuration_contact_information')]
64
    public ContactInformation $contactInformation;
65
66
    public static function create(
67
        string $id,
68
        Institution $institution,
69
        RaLocationName $name,
70
        Location $location,
71
        ContactInformation $contactInformation,
72
    ): self {
73
        $raLocation = new self;
0 ignored issues
show
Coding Style introduced by
Parentheses must be used when instantiating a new class
Loading history...
74
75
        $raLocation->id = $id;
76
        $raLocation->institution = $institution;
77
        $raLocation->name = $name;
78
        $raLocation->location = $location;
79
        $raLocation->contactInformation = $contactInformation;
80
81
        return $raLocation;
82
    }
83
84
    public function jsonSerialize(): array
85
    {
86
        return [
87
            'id' => $this->id,
88
            'institution' => $this->institution,
89
            'name' => $this->name,
90
            'location' => $this->location,
91
            'contact_information' => $this->contactInformation,
92
        ];
93
    }
94
}
95