Row   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 53
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A afterDelete() 0 3 1
A beforeUpdate() 0 3 1
A beforeSave() 0 5 1
A beforeInsert() 0 13 3
1
<?php
2
/**
3
 * @copyright Bluz PHP Team
4
 * @link https://github.com/bluzphp/skeleton
5
 */
6
7
declare(strict_types=1);
8
9
namespace Application\Media;
10
11
use Application\Users;
0 ignored issues
show
Bug introduced by
The type Application\Users was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Bluz\Proxy\Auth;
13
use Bluz\Validator\Traits\Validator;
14
use Zend\Diactoros\UploadedFile;
15
16
/**
17
 * Media Row
18
 *
19
 * @category Application
20
 * @package  Media
21
 *
22
 * @property integer $id
23
 * @property integer $userId
24
 * @property string $title
25
 * @property string $module
26
 * @property string $type
27
 * @property string $file
28
 * @property string $thumb
29
 * @property integer $size
30
 * @property string $created
31
 * @property string $updated
32
 */
33
class Row extends \Bluz\Db\Row
34
{
35
    use Validator;
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    protected function beforeSave() : void
41
    {
42
        $this->addValidator('title')
43
            ->required()
44
            ->latinNumeric(' -_.');
45
    }
46
47
    /**
48
     * __insert
49
     *
50
     * @return void
51
     */
52
    protected function beforeInsert() : void
53
    {
54
        $this->created = gmdate('Y-m-d H:i:s');
55
56
        // set default module
57
        if (!$this->module) {
58
            $this->module = 'users';
59
        }
60
        // set user ID
61
        if ($user = Auth::getIdentity()) {
62
            $this->userId = $user->getId();
63
        } else {
64
            $this->userId = Users\Table::SYSTEM_USER;
0 ignored issues
show
Bug introduced by
The type Application\Users\Table was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
65
        }
66
    }
67
68
    /**
69
     * __update
70
     *
71
     * @return void
72
     */
73
    protected function beforeUpdate() : void
74
    {
75
        $this->updated = gmdate('Y-m-d H:i:s');
76
    }
77
78
    /**
79
     * postDelete
80
     *
81
     * @return void
82
     */
83
    protected function afterDelete() : void
84
    {
85
        Service::delete($this);
86
    }
87
}
88