Form   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 173
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 15

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
1
<?php
2
3
namespace App\Entity;
4
5
use Ds\Component\Locale\Model\Type\Localizable;
6
use Ds\Component\Model\Attribute\Accessor;
7
use Ds\Component\Model\Type\Deletable;
8
use Ds\Component\Model\Type\Identifiable;
9
use Ds\Component\Model\Type\Ownable;
10
use Ds\Component\Model\Type\Uuidentifiable;
11
use Ds\Component\Model\Type\Versionable;
12
use Ds\Component\Tenant\Model\Attribute\Accessor as TenantAccessor;
13
use Ds\Component\Tenant\Model\Type\Tenantable;
14
use Ds\Component\Translation\Model\Type\Translatable;
15
use Ds\Component\Translation\Model\Attribute\Accessor as TranslationAccessor;
16
use Knp\DoctrineBehaviors\Model as Behavior;
17
18
use ApiPlatform\Core\Annotation\ApiResource;
19
use ApiPlatform\Core\Annotation\ApiProperty;
20
use App\Validator\Constraints\Form as FormAssert;
21
use Doctrine\ORM\Mapping as ORM;
22
use Ds\Component\Locale\Model\Annotation\Locale;
23
use Ds\Component\Translation\Model\Annotation\Translate;
24
use Symfony\Bridge\Doctrine\Validator\Constraints as ORMAssert;
25
use Symfony\Component\Serializer\Annotation as Serializer;
26
use Symfony\Component\Validator\Constraints as Assert;
27
28
/**
29
 * Class Form
30
 *
31
 * @ApiResource(
32
 *      attributes={
33
 *          "normalization_context"={
34
 *              "groups"={"form_output"}
35
 *          },
36
 *          "denormalization_context"={
37
 *              "groups"={"form_input"}
38
 *          },
39
 *          "filters"={
40
 *              "app.form.search",
41
 *              "app.form.search_translation",
42
 *              "app.form.date",
43
 *              "app.form.order"
44
 *          }
45
 *      }
46
 * )
47
 * @ORM\Entity(repositoryClass="App\Repository\FormRepository")
48
 * @ORM\Table(name="app_form")
49
 * @ORM\Cache(usage="NONSTRICT_READ_WRITE")
50
 * @FormAssert\Config\Valid
51
 */
52
class Form implements Identifiable, Uuidentifiable, Ownable, Translatable, Localizable, Deletable, Versionable, Tenantable
53
{
54
    use Behavior\Translatable\Translatable;
55
    use Behavior\Timestampable\Timestampable;
56
    use Behavior\SoftDeletable\SoftDeletable;
57
58
    use Accessor\Id;
59
    use Accessor\Uuid;
60
    use Accessor\Owner;
61
    use Accessor\OwnerUuid;
62
    use Accessor\Type;
63
    use Accessor\Config;
64
    use TranslationAccessor\Title;
65
    use TranslationAccessor\Description;
66
    use Accessor\Data;
67
    use Accessor\Deleted;
68
    use Accessor\Version;
69
    use TenantAccessor\Tenant;
70
71
    /**
72
     * @const string
73
     */
74
    const TYPE_FORMIO = 'formio';
75
76
    /**
77
     * @var integer
78
     * @ApiProperty(identifier=false, writable=false)
79
     * @Serializer\Groups({"form_output"})
80
     * @ORM\Id
81
     * @ORM\GeneratedValue(strategy="AUTO")
82
     * @ORM\Column(name="id", type="integer")
83
     */
84
    private $id;
85
86
    /**
87
     * @var string
88
     * @ApiProperty(identifier=true, writable=false)
89
     * @Serializer\Groups({"form_output"})
90
     * @ORM\Column(name="uuid", type="guid", unique=true)
91
     * @Assert\Uuid
92
     */
93
    private $uuid;
94
95
    /**
96
     * @var \DateTime
97
     * @ApiProperty(writable=false)
98
     * @Serializer\Groups({"form_output"})
99
     */
100
    protected $createdAt;
101
102
    /**
103
     * @var \DateTime
104
     * @ApiProperty(writable=false)
105
     * @Serializer\Groups({"form_output"})
106
     */
107
    protected $updatedAt;
108
109
    /**
110
     * @var \DateTime
111
     * @ApiProperty(writable=false)
112
     * @Serializer\Groups({"form_output"})
113
     */
114
    protected $deletedAt;
115
116
    /**
117
     * @var string
118
     * @ApiProperty
119
     * @Serializer\Groups({"form_output", "form_input"})
120
     * @ORM\Column(name="`owner`", type="string", length=255, nullable=true)
121
     * @Assert\NotBlank
122
     * @Assert\Length(min=1, max=255)
123
     */
124
    private $owner;
125
126
    /**
127
     * @var string
128
     * @ApiProperty
129
     * @Serializer\Groups({"form_output", "form_input"})
130
     * @ORM\Column(name="owner_uuid", type="guid", nullable=true)
131
     * @Assert\NotBlank
132
     * @Assert\Uuid
133
     */
134
    private $ownerUuid;
135
136
    /**
137
     * @var string
138
     * @ApiProperty
139
     * @Serializer\Groups({"form_output", "form_input"})
140
     * @ORM\Column(name="type", type="string", length=255, nullable=true)
141
     * @Assert\NotBlank
142
     * @Assert\Length(min=1, max=255)
143
     */
144
    private $type;
145
146
    /**
147
     * @var array
148
     * @ApiProperty
149
     * @Serializer\Groups({"form_output", "form_input"})
150
     * @ORM\Column(name="config", type="json_array")
151
     * @Assert\Type("array")
152
     */
153
    private $config;
154
155
    /**
156
     * @var array
157
     * @ApiProperty
158
     * @Serializer\Groups({"form_output", "form_input"})
159
     * @Assert\Type("array")
160
     * @Assert\NotBlank
161
     * @Assert\All({
162
     *     @Assert\NotBlank,
163
     *     @Assert\Length(min=1)
164
     * })
165
     * @Locale
166
     * @Translate
167
     */
168
    private $title;
169
170
    /**
171
     * @var array
172
     * @ApiProperty
173
     * @Serializer\Groups({"form_output", "form_input"})
174
     * @Assert\Type("array")
175
     * @Assert\NotBlank
176
     * @Assert\All({
177
     *     @Assert\NotBlank,
178
     *     @Assert\Length(min=1)
179
     * })
180
     * @Locale
181
     * @Translate
182
     */
183
    private $description;
184
185
    /**
186
     * @var array
187
     * @ApiProperty
188
     * @Serializer\Groups({"form_output", "form_input"})
189
     * @ORM\Column(name="data", type="json_array")
190
     * @Assert\Type("array")
191
     */
192
    private $data;
193
194
    /**
195
     * @var integer
196
     * @ApiProperty
197
     * @Serializer\Groups({"form_output", "form_input"})
198
     * @ORM\Column(name="version", type="integer")
199
     * @ORM\Version
200
     * @Assert\NotBlank
201
     * @Assert\Type("integer")
202
     */
203
    private $version;
204
205
    /**
206
     * @var string
207
     * @ApiProperty(writable=false)
208
     * @Serializer\Groups({"form_output"})
209
     * @ORM\Column(name="tenant", type="guid")
210
     * @Assert\Uuid
211
     */
212
    private $tenant;
213
214
    /**
215
     * Constructor
216
     */
217
    public function __construct()
218
    {
219
        $this->config = [];
220
        $this->title = [];
221
        $this->description = [];
222
        $this->data = [];
223
    }
224
}
225