Test Failed
Push — master ( 35ab15...7ed30e )
by Julien
04:21
created

AbstractLog   B

Complexity

Total Complexity 44

Size/Duplication

Total Lines 644
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 106
dl 0
loc 644
ccs 0
cts 129
cp 0
rs 8.8798
c 0
b 0
f 0
wmc 44

44 Methods

Rating   Name   Duplication   Size   Complexity  
A getUpdatedAt() 0 3 1
A setCreatedAt() 0 5 1
A findFirst() 0 3 1
A getRestoredBy() 0 3 1
A getMessage() 0 3 1
A getRestoredAs() 0 3 1
A setLevel() 0 5 1
A find() 0 3 1
A getCreatedAs() 0 3 1
A getDeletedAt() 0 3 1
A setDate() 0 5 1
A setUpdatedAs() 0 5 1
A setRestoredAt() 0 5 1
A getId() 0 3 1
A getUpdatedBy() 0 3 1
A setDeletedBy() 0 5 1
A setDeletedAs() 0 5 1
A setId() 0 5 1
A setDeleted() 0 5 1
A setType() 0 5 1
A setUpdatedBy() 0 5 1
A getRestoredAt() 0 3 1
A setRestoredAs() 0 5 1
A setUpdatedAt() 0 5 1
A getDeletedBy() 0 3 1
A getDeletedAs() 0 3 1
A getType() 0 3 1
A setDeletedAt() 0 5 1
A getCreatedAt() 0 3 1
A setRestoredBy() 0 5 1
A getContext() 0 3 1
A columnMap() 0 23 1
A getDate() 0 3 1
A setCreatedBy() 0 5 1
A setName() 0 5 1
A setMessage() 0 5 1
A setCreatedAs() 0 5 1
A getName() 0 3 1
A getDeleted() 0 3 1
A getCreatedBy() 0 3 1
A setContext() 0 5 1
A getLevel() 0 3 1
A getUpdatedAs() 0 3 1
A initialize() 0 5 1

How to fix   Complexity   

Complex Class

Complex classes like AbstractLog often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use AbstractLog, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/**
4
 * This file is part of the Zemit Framework.
5
 *
6
 * (c) Zemit Team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.txt
9
 * file that was distributed with this source code.
10
 *
11
 * --------------------------------------------------------------
12
 *
13
 * New BSD License
14
 *
15
 * Copyright (c) 2017-present, Zemit CMS Team
16
 * All rights reserved.
17
 *
18
 * Redistribution and use in source and binary forms, with or without
19
 * modification, are permitted provided that the following conditions are met:
20
 *     * Redistributions of source code must retain the above copyright
21
 *       notice, this list of conditions and the following disclaimer.
22
 *     * Redistributions in binary form must reproduce the above copyright
23
 *       notice, this list of conditions and the following disclaimer in the
24
 *       documentation and/or other materials provided with the distribution.
25
 *     * Neither the name of the Zemit nor the
26
 *       names of its contributors may be used to endorse or promote products
27
 *       derived from this software without specific prior written permission.
28
 *
29
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
30
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32
 * DISCLAIMED. IN NO EVENT SHALL ZEMIT FRAMEWORK TEAM BE LIABLE FOR ANY
33
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
 */
40
41
namespace Zemit\Models\Abstracts;
42
43
use Phalcon\Mvc\ModelInterface;
44
use Phalcon\Mvc\Model\ResultInterface;
45
use Phalcon\Mvc\Model\ResultsetInterface;
46
use Zemit\Models\AbstractModel;
47
48
/**
49
 * AbstractLog
50
 * @package Zemit\Models\Base
51
 * @autogenerated by Phalcon Developer Tools
52
 * @date 2023-03-30, 04:45:31
53
 */
54
abstract class AbstractLog extends AbstractModel
55
{
56
    /**
57
     * @var integer
58
     * @Primary
59
     * @Column(column="id", type="integer", nullable=false)
60
     */
61
    protected $id;
62
63
    /**
64
     * @var integer
65
     * @Column(column="level", type="integer", nullable=false)
66
     */
67
    protected $level;
68
69
    /**
70
     * @var string
71
     * @Column(column="type", type="string", length='critical','alert','error','warning','notice','info','debug','emergency','other', nullable=false)
72
     */
73
    protected $type;
74
75
    /**
76
     * @var string
77
     * @Column(column="name", type="string", length=255, nullable=false)
78
     */
79
    protected $name;
80
81
    /**
82
     * @var string
83
     * @Column(column="message", type="string", nullable=false)
84
     */
85
    protected $message;
86
87
    /**
88
     * @var string
89
     * @Column(column="context", type="string", nullable=false)
90
     */
91
    protected $context;
92
93
    /**
94
     * @var string
95
     * @Column(column="date", type="string", nullable=false)
96
     */
97
    protected $date;
98
99
    /**
100
     * @var integer
101
     * @Column(column="deleted", type="integer", nullable=false)
102
     */
103
    protected $deleted;
104
105
    /**
106
     * @var string
107
     * @Column(column="created_at", type="string", nullable=false)
108
     */
109
    protected $createdAt;
110
111
    /**
112
     * @var integer
113
     * @Column(column="created_by", type="integer", nullable=true)
114
     */
115
    protected $createdBy;
116
117
    /**
118
     * @var integer
119
     * @Column(column="created_as", type="integer", nullable=true)
120
     */
121
    protected $createdAs;
122
123
    /**
124
     * @var string
125
     * @Column(column="updated_at", type="string", nullable=true)
126
     */
127
    protected $updatedAt;
128
129
    /**
130
     * @var integer
131
     * @Column(column="updated_by", type="integer", nullable=true)
132
     */
133
    protected $updatedBy;
134
135
    /**
136
     * @var integer
137
     * @Column(column="updated_as", type="integer", nullable=true)
138
     */
139
    protected $updatedAs;
140
141
    /**
142
     * @var string
143
     * @Column(column="deleted_at", type="string", nullable=true)
144
     */
145
    protected $deletedAt;
146
147
    /**
148
     * @var integer
149
     * @Column(column="deleted_as", type="integer", nullable=true)
150
     */
151
    protected $deletedAs;
152
153
    /**
154
     * @var integer
155
     * @Column(column="deleted_by", type="integer", nullable=true)
156
     */
157
    protected $deletedBy;
158
159
    /**
160
     * @var string
161
     * @Column(column="restored_at", type="string", nullable=true)
162
     */
163
    protected $restoredAt;
164
165
    /**
166
     * @var integer
167
     * @Column(column="restored_by", type="integer", nullable=true)
168
     */
169
    protected $restoredBy;
170
171
    /**
172
     * @var integer
173
     * @Column(column="restored_as", type="integer", nullable=true)
174
     */
175
    protected $restoredAs;
176
177
    /**
178
     * Method to set the value of field id
179
     *
180
     * @param integer $id
181
     * @return $this
182
     */
183
    public function setId($id)
184
    {
185
        $this->id = $id;
186
187
        return $this;
188
    }
189
190
    /**
191
     * Returns the value of field id
192
     *
193
     * @return integer
194
     */
195
    public function getId()
196
    {
197
        return $this->id;
198
    }
199
200
    /**
201
     * Method to set the value of field level
202
     *
203
     * @param integer $level
204
     * @return $this
205
     */
206
    public function setLevel($level)
207
    {
208
        $this->level = $level;
209
210
        return $this;
211
    }
212
213
    /**
214
     * Returns the value of field level
215
     *
216
     * @return integer
217
     */
218
    public function getLevel()
219
    {
220
        return $this->level;
221
    }
222
223
    /**
224
     * Method to set the value of field type
225
     *
226
     * @param string $type
227
     * @return $this
228
     */
229
    public function setType($type)
230
    {
231
        $this->type = $type;
232
233
        return $this;
234
    }
235
236
    /**
237
     * Returns the value of field type
238
     *
239
     * @return string
240
     */
241
    public function getType()
242
    {
243
        return $this->type;
244
    }
245
246
    /**
247
     * Method to set the value of field name
248
     *
249
     * @param string $name
250
     * @return $this
251
     */
252
    public function setName($name)
253
    {
254
        $this->name = $name;
255
256
        return $this;
257
    }
258
259
    /**
260
     * Returns the value of field name
261
     *
262
     * @return string
263
     */
264
    public function getName()
265
    {
266
        return $this->name;
267
    }
268
269
    /**
270
     * Method to set the value of field message
271
     *
272
     * @param string $message
273
     * @return $this
274
     */
275
    public function setMessage($message)
276
    {
277
        $this->message = $message;
278
279
        return $this;
280
    }
281
282
    /**
283
     * Returns the value of field message
284
     *
285
     * @return string
286
     */
287
    public function getMessage()
288
    {
289
        return $this->message;
290
    }
291
292
    /**
293
     * Method to set the value of field context
294
     *
295
     * @param string $context
296
     * @return $this
297
     */
298
    public function setContext($context)
299
    {
300
        $this->context = $context;
301
302
        return $this;
303
    }
304
305
    /**
306
     * Returns the value of field context
307
     *
308
     * @return string
309
     */
310
    public function getContext()
311
    {
312
        return $this->context;
313
    }
314
315
    /**
316
     * Method to set the value of field date
317
     *
318
     * @param string $date
319
     * @return $this
320
     */
321
    public function setDate($date)
322
    {
323
        $this->date = $date;
324
325
        return $this;
326
    }
327
328
    /**
329
     * Returns the value of field date
330
     *
331
     * @return string
332
     */
333
    public function getDate()
334
    {
335
        return $this->date;
336
    }
337
338
    /**
339
     * Method to set the value of field deleted
340
     *
341
     * @param integer $deleted
342
     * @return $this
343
     */
344
    public function setDeleted($deleted)
345
    {
346
        $this->deleted = $deleted;
347
348
        return $this;
349
    }
350
351
    /**
352
     * Returns the value of field deleted
353
     *
354
     * @return integer
355
     */
356
    public function getDeleted()
357
    {
358
        return $this->deleted;
359
    }
360
361
    /**
362
     * Method to set the value of field created_at
363
     *
364
     * @param string $createdAt
365
     * @return $this
366
     */
367
    public function setCreatedAt($createdAt)
368
    {
369
        $this->createdAt = $createdAt;
370
371
        return $this;
372
    }
373
374
    /**
375
     * Returns the value of field created_at
376
     *
377
     * @return string
378
     */
379
    public function getCreatedAt()
380
    {
381
        return $this->createdAt;
382
    }
383
384
    /**
385
     * Method to set the value of field created_by
386
     *
387
     * @param integer $createdBy
388
     * @return $this
389
     */
390
    public function setCreatedBy($createdBy)
391
    {
392
        $this->createdBy = $createdBy;
393
394
        return $this;
395
    }
396
397
    /**
398
     * Returns the value of field created_by
399
     *
400
     * @return integer
401
     */
402
    public function getCreatedBy()
403
    {
404
        return $this->createdBy;
405
    }
406
407
    /**
408
     * Method to set the value of field created_as
409
     *
410
     * @param integer $createdAs
411
     * @return $this
412
     */
413
    public function setCreatedAs($createdAs)
414
    {
415
        $this->createdAs = $createdAs;
416
417
        return $this;
418
    }
419
420
    /**
421
     * Returns the value of field created_as
422
     *
423
     * @return integer
424
     */
425
    public function getCreatedAs()
426
    {
427
        return $this->createdAs;
428
    }
429
430
    /**
431
     * Method to set the value of field updated_at
432
     *
433
     * @param string $updatedAt
434
     * @return $this
435
     */
436
    public function setUpdatedAt($updatedAt)
437
    {
438
        $this->updatedAt = $updatedAt;
439
440
        return $this;
441
    }
442
443
    /**
444
     * Returns the value of field updated_at
445
     *
446
     * @return string
447
     */
448
    public function getUpdatedAt()
449
    {
450
        return $this->updatedAt;
451
    }
452
453
    /**
454
     * Method to set the value of field updated_by
455
     *
456
     * @param integer $updatedBy
457
     * @return $this
458
     */
459
    public function setUpdatedBy($updatedBy)
460
    {
461
        $this->updatedBy = $updatedBy;
462
463
        return $this;
464
    }
465
466
    /**
467
     * Returns the value of field updated_by
468
     *
469
     * @return integer
470
     */
471
    public function getUpdatedBy()
472
    {
473
        return $this->updatedBy;
474
    }
475
476
    /**
477
     * Method to set the value of field updated_as
478
     *
479
     * @param integer $updatedAs
480
     * @return $this
481
     */
482
    public function setUpdatedAs($updatedAs)
483
    {
484
        $this->updatedAs = $updatedAs;
485
486
        return $this;
487
    }
488
489
    /**
490
     * Returns the value of field updated_as
491
     *
492
     * @return integer
493
     */
494
    public function getUpdatedAs()
495
    {
496
        return $this->updatedAs;
497
    }
498
499
    /**
500
     * Method to set the value of field deleted_at
501
     *
502
     * @param string $deletedAt
503
     * @return $this
504
     */
505
    public function setDeletedAt($deletedAt)
506
    {
507
        $this->deletedAt = $deletedAt;
508
509
        return $this;
510
    }
511
512
    /**
513
     * Returns the value of field deleted_at
514
     *
515
     * @return string
516
     */
517
    public function getDeletedAt()
518
    {
519
        return $this->deletedAt;
520
    }
521
522
    /**
523
     * Method to set the value of field deleted_as
524
     *
525
     * @param integer $deletedAs
526
     * @return $this
527
     */
528
    public function setDeletedAs($deletedAs)
529
    {
530
        $this->deletedAs = $deletedAs;
531
532
        return $this;
533
    }
534
535
    /**
536
     * Returns the value of field deleted_as
537
     *
538
     * @return integer
539
     */
540
    public function getDeletedAs()
541
    {
542
        return $this->deletedAs;
543
    }
544
545
    /**
546
     * Method to set the value of field deleted_by
547
     *
548
     * @param integer $deletedBy
549
     * @return $this
550
     */
551
    public function setDeletedBy($deletedBy)
552
    {
553
        $this->deletedBy = $deletedBy;
554
555
        return $this;
556
    }
557
558
    /**
559
     * Returns the value of field deleted_by
560
     *
561
     * @return integer
562
     */
563
    public function getDeletedBy()
564
    {
565
        return $this->deletedBy;
566
    }
567
568
    /**
569
     * Method to set the value of field restored_at
570
     *
571
     * @param string $restoredAt
572
     * @return $this
573
     */
574
    public function setRestoredAt($restoredAt)
575
    {
576
        $this->restoredAt = $restoredAt;
577
578
        return $this;
579
    }
580
581
    /**
582
     * Returns the value of field restored_at
583
     *
584
     * @return string
585
     */
586
    public function getRestoredAt()
587
    {
588
        return $this->restoredAt;
589
    }
590
591
    /**
592
     * Method to set the value of field restored_by
593
     *
594
     * @param integer $restoredBy
595
     * @return $this
596
     */
597
    public function setRestoredBy($restoredBy)
598
    {
599
        $this->restoredBy = $restoredBy;
600
601
        return $this;
602
    }
603
604
    /**
605
     * Returns the value of field restored_by
606
     *
607
     * @return integer
608
     */
609
    public function getRestoredBy()
610
    {
611
        return $this->restoredBy;
612
    }
613
614
    /**
615
     * Method to set the value of field restored_as
616
     *
617
     * @param integer $restoredAs
618
     * @return $this
619
     */
620
    public function setRestoredAs($restoredAs)
621
    {
622
        $this->restoredAs = $restoredAs;
623
624
        return $this;
625
    }
626
627
    /**
628
     * Returns the value of field restored_as
629
     *
630
     * @return integer
631
     */
632
    public function getRestoredAs()
633
    {
634
        return $this->restoredAs;
635
    }
636
637
    /**
638
     * Initialize method for model.
639
     */
640
    public function initialize(): void
641
    {
642
		parent::initialize();
643
        // $this->setSchema('zemit_core');
644
        $this->setSource('log');
645
    }
646
647
    /**
648
     * Allows to query a set of records that match the specified conditions
649
     *
650
     * @param mixed $parameters
651
     * @return AbstractLog[]|AbstractLog|ResultsetInterface
652
     */
653
    public static function find($parameters = null): ResultsetInterface
654
    {
655
        return parent::find($parameters);
656
    }
657
658
    /**
659
     * Allows to query the first record that match the specified conditions
660
     *
661
     * @param mixed $parameters
662
     * @return AbstractLog|ResultInterface|ModelInterface|null
663
     */
664
    public static function findFirst($parameters = null): ?ModelInterface
665
    {
666
        return parent::findFirst($parameters);
667
    }
668
669
    /**
670
     * Independent Column Mapping.
671
     * Keys are the real names in the table and the values their names in the application
672
     *
673
     * @return array
674
     */
675
    public function columnMap()
676
    {
677
        return [
678
            'id' => 'id',
679
            'level' => 'level',
680
            'type' => 'type',
681
            'name' => 'name',
682
            'message' => 'message',
683
            'context' => 'context',
684
            'date' => 'date',
685
            'deleted' => 'deleted',
686
            'created_at' => 'createdAt',
687
            'created_by' => 'createdBy',
688
            'created_as' => 'createdAs',
689
            'updated_at' => 'updatedAt',
690
            'updated_by' => 'updatedBy',
691
            'updated_as' => 'updatedAs',
692
            'deleted_at' => 'deletedAt',
693
            'deleted_as' => 'deletedAs',
694
            'deleted_by' => 'deletedBy',
695
            'restored_at' => 'restoredAt',
696
            'restored_by' => 'restoredBy',
697
            'restored_as' => 'restoredAs',
698
        ];
699
    }
700
}
701