Issues (3627)

bundles/IntegrationsBundle/Entity/FieldChange.php (5 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * @copyright   2018 Mautic Inc. All rights reserved
7
 * @author      Mautic, Inc.
8
 *
9
 * @link        https://www.mautic.com
10
 *
11
 * @license     GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
12
 */
13
14
namespace Mautic\IntegrationsBundle\Entity;
15
16
use Doctrine\DBAL\Types\Type;
17
use Doctrine\ORM\Mapping as ORM;
18
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
19
20
class FieldChange
21
{
22
    /**
23
     * @var int
24
     */
25
    private $id;
26
27
    /**
28
     * @var string
29
     */
30
    private $integration;
31
32
    /**
33
     * @var int
34
     */
35
    private $objectId;
36
37
    /**
38
     * @var string
39
     */
40
    private $objectType;
41
42
    /**
43
     * @var \DateTime
44
     */
45
    private $modifiedAt;
46
47
    /**
48
     * @var string
49
     */
50
    private $columnName;
51
52
    /**
53
     * @var string
54
     */
55
    private $columnType;
56
57
    /**
58
     * @var string
59
     */
60
    private $columnValue;
61
62
    public static function loadMetadata(ORM\ClassMetadata $metadata): void
63
    {
64
        $builder = new ClassMetadataBuilder($metadata);
65
66
        $builder
67
            ->setTable('sync_object_field_change_report')
68
            ->setCustomRepositoryClass(FieldChangeRepository::class)
69
            ->addIndex(['object_type', 'object_id', 'column_name'], 'object_composite_key')
70
            ->addIndex(['integration', 'object_type', 'object_id', 'column_name'], 'integration_object_composite_key')
71
            ->addIndex(['integration', 'object_type', 'modified_at'], 'integration_object_type_modification_composite_key');
72
73
        $builder->addId();
74
75
        $builder
76
            ->createField('integration', Type::STRING)
77
            ->build();
78
79
        $builder->addBigIntIdField('objectId', 'object_id', false);
80
81
        $builder
82
            ->createField('objectType', Type::STRING)
0 ignored issues
show
Deprecated Code introduced by
The constant Doctrine\DBAL\Types\Type::STRING has been deprecated: Use {@see Types::STRING} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

82
            ->createField('objectType', /** @scrutinizer ignore-deprecated */ Type::STRING)

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
83
            ->columnName('object_type')
84
            ->build();
85
86
        $builder
87
            ->createField('modifiedAt', Type::DATETIME)
0 ignored issues
show
Deprecated Code introduced by
The constant Doctrine\DBAL\Types\Type::DATETIME has been deprecated: Use {@see Types::DATETIME_MUTABLE} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

87
            ->createField('modifiedAt', /** @scrutinizer ignore-deprecated */ Type::DATETIME)

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
88
            ->columnName('modified_at')
89
            ->build();
90
91
        $builder
92
            ->createField('columnName', Type::STRING)
0 ignored issues
show
Deprecated Code introduced by
The constant Doctrine\DBAL\Types\Type::STRING has been deprecated: Use {@see Types::STRING} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

92
            ->createField('columnName', /** @scrutinizer ignore-deprecated */ Type::STRING)

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
93
            ->columnName('column_name')
94
            ->build();
95
96
        $builder
97
            ->createField('columnType', Type::STRING)
0 ignored issues
show
Deprecated Code introduced by
The constant Doctrine\DBAL\Types\Type::STRING has been deprecated: Use {@see Types::STRING} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

97
            ->createField('columnType', /** @scrutinizer ignore-deprecated */ Type::STRING)

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
98
            ->columnName('column_type')
99
            ->build();
100
101
        $builder
102
            ->createField('columnValue', Type::STRING)
0 ignored issues
show
Deprecated Code introduced by
The constant Doctrine\DBAL\Types\Type::STRING has been deprecated: Use {@see Types::STRING} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

102
            ->createField('columnValue', /** @scrutinizer ignore-deprecated */ Type::STRING)

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
103
            ->columnName('column_value')
104
            ->build();
105
    }
106
107
    /**
108
     * @return int
109
     */
110
    public function getId()
111
    {
112
        return $this->id;
113
    }
114
115
    public function getIntegration(): string
116
    {
117
        return $this->integration;
118
    }
119
120
    /**
121
     * @param string $integration
122
     *
123
     * @return FieldChange
124
     */
125
    public function setIntegration($integration)
126
    {
127
        $this->integration = $integration;
128
129
        return $this;
130
    }
131
132
    /**
133
     * @return FieldChange
134
     */
135
    public function setObjectId(int $id): self
136
    {
137
        $this->objectId = $id;
138
139
        return $this;
140
    }
141
142
    public function getObjectId(): int
143
    {
144
        return $this->objectId;
145
    }
146
147
    /**
148
     * @return FieldChange
149
     */
150
    public function setObjectType(string $type): self
151
    {
152
        $this->objectType = $type;
153
154
        return $this;
155
    }
156
157
    public function getObjectType(): string
158
    {
159
        return $this->objectType;
160
    }
161
162
    /**
163
     * @return FieldChange
164
     */
165
    public function setModifiedAt(\DateTime $time): self
166
    {
167
        $this->modifiedAt = $time;
168
169
        return $this;
170
    }
171
172
    public function getModifiedAt(): \DateTime
173
    {
174
        return $this->modifiedAt;
175
    }
176
177
    /**
178
     * @return FieldChange
179
     */
180
    public function setColumnName(string $name): self
181
    {
182
        $this->columnName = $name;
183
184
        return $this;
185
    }
186
187
    public function getColumnName(): string
188
    {
189
        return $this->columnName;
190
    }
191
192
    /**
193
     * @return FieldChange
194
     */
195
    public function setColumnType(string $type): self
196
    {
197
        $this->columnType = $type;
198
199
        return $this;
200
    }
201
202
    public function getColumnType(): string
203
    {
204
        return $this->columnType;
205
    }
206
207
    /**
208
     * @return FieldChange
209
     */
210
    public function setColumnValue(string $value): self
211
    {
212
        $this->columnValue = $value;
213
214
        return $this;
215
    }
216
217
    public function getColumnValue(): string
218
    {
219
        return $this->columnValue;
220
    }
221
}
222