Test Failed
Pull Request — master (#70)
by Rafael
06:01
created

NotificationsTrait::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 11
nc 2
nop 4
dl 0
loc 14
ccs 0
cts 13
cp 0
crap 6
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gewaer\Traits;
6
7
use Gewaer\Models\Users;
8
use Gewaer\Models\SystemModules;
9
use Gewaer\Models\Notifications;
10
use Phalcon\Di;
11
12
/**
13
 * Trait ResponseTrait
14
 *
15
 * @package Gewaer\Traits
16
 *
17
 * @property Users $user
18
 * @property AppsPlans $appPlan
19
 * @property CompanyBranches $branches
20
 * @property Companies $company
21
 * @property UserCompanyApps $app
22
 * @property \Phalcon\Di $di
23
 *
24
 */
25
trait NotificationsTrait
26
{
27
    /**
28
     * Create a new notification
29
     * @param Users $user
30
     * @param string $content
31
     * @param int notification_type_id
0 ignored issues
show
Bug introduced by
The type Gewaer\Traits\notification_type_id 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...
32
     * @param string systemModule;
0 ignored issues
show
Bug introduced by
The type Gewaer\Traits\systemModule 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...
33
     * @return void
34
     */
35
    public static function create(Users $user, string $content, int $notificationTypeId,string $systemModule): void
0 ignored issues
show
Coding Style introduced by
Expected 1 space between comma and type hint "string"; 0 found
Loading history...
36
    {
37
        $notification =  new Notifications();
38
        $notification->users_id = $user->getId();
39
        $notification->companies_id = Di::getDefault()->getUserData()->currentCompanyId();
40
        $notification->apps_id = Di::getDefault()->getApp()->getId();
41
        $notification->notification_type_id = $notificationTypeId;
0 ignored issues
show
Bug Best Practice introduced by
The property notification_type_id does not exist on Gewaer\Models\Notifications. Since you implemented __set, consider adding a @property annotation.
Loading history...
42
        $notification->system_module_id = SystemModules::getSystemModuleByModelName($systemModule)->id;
0 ignored issues
show
Bug Best Practice introduced by
The property system_module_id does not exist on Gewaer\Models\Notifications. Since you implemented __set, consider adding a @property annotation.
Loading history...
43
        $notification->entity_id = $user->getId();
44
        $notification->content = $content;
45
        $notification->created_at = date('Y-m-d H:i:s');
46
47
        if(!$notification->save()){
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) after IF keyword; 0 found
Loading history...
48
            Di::getDefault()->getLog()->error((string)current($notification->getMessages()));
49
        }
50
    }
51
}