Completed
Pull Request — master (#164)
by Ihor
25:00 queued 13:13
created

UserRequest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 154
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 154
ccs 0
cts 35
cp 0
rs 10
wmc 8
lcom 0
cbo 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getFirstName() 0 4 1
A getLastName() 0 4 1
A getEmail() 0 4 1
A getSocialNetwork() 0 4 1
A getSocialNetworks() 0 6 1
A getSocialToken() 0 4 1
A setApiKey() 0 6 1
A getApiKey() 0 4 1
1
<?php
2
3
namespace AppBundle\Model;
4
5
use Symfony\Component\Validator\Constraints as Assert;
6
use JMS\Serializer\Annotation\Accessor;
7
use JMS\Serializer\Annotation\ExclusionPolicy;
8
use JMS\Serializer\Annotation\Expose;
9
use JMS\Serializer\Annotation\Type;
10
11
/**
12
 * @ExclusionPolicy("all")
13
 */
14
class UserRequest
15
{
16
    const SOCIAL_NETWORK_FACEBOOK = 'facebook';
17
18
    /**
19
     * @var string
20
     *
21
     * @Assert\Regex(pattern="/\d/", match=false, groups={"update"})
22
     * @Assert\Type("string", groups={"update"})
23
     * @Assert\Length(min=2, max=100, groups={"update"})
24
     * @Assert\NotBlank(
25
     *     message="not.blank", groups={"update"}
26
     * )
27
     *
28
     * @Type("string")
29
     * @Accessor(getter="getFirstName")
30
     * @Expose
31
     */
32
    protected $firstName;
33
34
    /**
35
     * @var string
36
     *
37
     * @Assert\Regex(pattern="/\d/", match=false, groups={"update"})
38
     * @Assert\Type("string", groups={"update"})
39
     * @Assert\Length(min=2, max=100, groups={"update"})
40
     * @Assert\NotBlank(
41
     *     message="not.blank", groups={"update"}
42
     * )
43
     *
44
     * @Type("string")
45
     * @Accessor(getter="getLastName")
46
     * @Expose
47
     */
48
    protected $lastName;
49
50
    /**
51
     * @var string
52
     *
53
     * @Assert\Email(groups={"update"})
54
     * @Assert\Type("string", groups={"update"})
55
     * @Assert\Length(max=100, groups={"update"})
56
     * @Assert\NotBlank(
57
     *     message="not.blank", groups={"update"}
58
     * )
59
     *
60
     * @Type("string")
61
     * @Accessor(getter="getEmail")
62
     * @Expose
63
     */
64
    protected $email;
65
66
    /**
67
     * @var string
68
     *
69
     * @Type("string")
70
     * @Accessor(getter="getApiKey")
71
     * @Expose
72
     */
73
    protected $apiKey;
74
75
    /**
76
     * @var string
77
     *
78
     * @Assert\NotBlank(groups={"socialNetwork"})
79
     * @Assert\Choice(callback="getSocialNetworks", groups={"socialNetwork"})
80
     *
81
     * @Type("string")
82
     * @Accessor(getter="getSocialNetwork")
83
     * @Expose
84
     */
85
    protected $socialNetwork;
86
87
    /**
88
     * @var string
89
     *
90
     * @Assert\NotBlank(groups={"socialNetwork"})
91
     *
92
     * @Type("string")
93
     * @Accessor(getter="getSocialToken")
94
     * @Expose
95
     */
96
    protected $socialToken;
97
98
    /**
99
     * @return string
100
     */
101
    public function getFirstName(): ?string
102
    {
103
        return $this->firstName;
104
    }
105
106
    /**
107
     * @return string
108
     */
109
    public function getLastName(): ?string
110
    {
111
        return $this->lastName;
112
    }
113
114
    /**
115
     * @return string
116
     */
117
    public function getEmail(): string
118
    {
119
        return $this->email;
120
    }
121
122
    /**
123
     * @return string
124
     */
125
    public function getSocialNetwork(): string
126
    {
127
        return $this->socialNetwork;
128
    }
129
130
    /**
131
     * @return array
132
     */
133
    public static function getSocialNetworks(): ?array
134
    {
135
        return [
136
            self::SOCIAL_NETWORK_FACEBOOK,
137
        ];
138
    }
139
140
    /**
141
     * @return string
142
     */
143
    public function getSocialToken(): ?string
144
    {
145
        return $this->socialToken;
146
    }
147
148
    /**
149
     * @param string $apiKey
150
     *
151
     * @return UserRequest
152
     */
153
    public function setApiKey(?string $apiKey): UserRequest
154
    {
155
        $this->apiKey = $apiKey;
156
157
        return $this;
158
    }
159
160
    /**
161
     * @return string
162
     */
163
    public function getApiKey(): ?string
164
    {
165
        return $this->apiKey;
166
    }
167
}
168