Test Failed
Pull Request — master (#70)
by Rafael
05:59
created

PushNotifications::apps()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 11
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Gewaer\Notifications\PushNotifications;
4
5
use Namshi\Notificator\Notification;
6
use Gewaer\Contracts\PushNotificationsContract;
7
use Gewaer\Models\Users;
8
use Gewaer\Notifications\PushNotifications\AppsPushNotifications;
9
use Gewaer\Notifications\PushNotifications\UsersPushNotifications;
10
use Gewaer\Notifications\PushNotifications\SystemPushNotifications;
11
use Phalcon\Di;
12
13
class PushNotifications extends Notification implements PushNotificationsContract
14
{
15
16
    public $user;
17
18
    public $content;
19
20
    public $systemModule;
21
22
    public function __construct(string $content)
23
    {
24
        $this->content  = $content;
25
    }
26
27
    /**
28
     * Assemble Notification
29
     */
30
    public function assemble()
31
    {
32
        return $this->content;
33
    }
34
35
    /**
36
     * Create a new Apps Notification
37
     * @return void
38
     */
39
    public static function apps(string $content, string $systemModule): void
40
    {
41
        /**
42
         * Create a new Apps Push Notification
43
         */
44
        $notification =  new AppsPushNotifications(Di::getDefault()->getUserData(),$content,$systemModule);
45
46
        /**
47
         * Send to notifications queue
48
         */
49
        Di::getDefault()->getManager()->trigger($notification);
50
    }
51
52
    /**
53
     * Create a new Users Notification
54
     * @return void
55
     */
56
    public static function users(string $content, string $systemModule): void
57
    {
58
        /**
59
         * Create a new Apps Push Notification
60
         */
61
        $notification =  new UsersPushNotifications(Di::getDefault()->getUserData(),$content,$systemModule);
62
63
        /**
64
         * Send to notifications queue
65
         */
66
        Di::getDefault()->getManager()->trigger($notification);
67
    }
68
69
    /**
70
     * Create a new System Notification
71
     * @return void
72
     */
73
    public static function system(string $content, string $systemModule): void
74
    {
75
        /**
76
         * Create a new Apps Push Notification
77
         */
78
        $notification =  new SystemPushNotifications(Di::getDefault()->getUserData(),$content,$systemModule);
79
80
        /**
81
         * Send to notifications queue
82
         */
83
        Di::getDefault()->getManager()->trigger($notification);
84
    }
85
}
86