Test Failed
Pull Request — master (#123)
by Maximo
06:15
created

Notify::all()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 2
c 1
b 0
f 1
nc 2
nop 2
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Canvas\Notifications;
6
7
use Canvas\Contracts\Notifications\NotificationInterfase;
8
use Canvas\Models\Users;
9
use Phalcon\Di;
10
11
class Notify
12
{
13
    /**
14
     * Send the nofitication to all the users.
15
     *
16
     * @param array $users
17
     * @param NotificationInterfase $notification
18
     * @return void
19
     */
20
    public static function all(array $users, NotificationInterfase $notification)
21
    {
22
        foreach ($users as $user) {
23
            $this->one($user, $notification);
0 ignored issues
show
Comprehensibility Best Practice introduced by
Using $this inside a static method is generally not recommended and can lead to errors in newer PHP versions.
Loading history...
24
        }
25
    }
26
27
    /**
28
     * Process just one.
29
     *
30
     * @param Users $user
31
     * @param NotificationInterfase $notification
32
     * @return void
33
     */
34
    public static function one(Users $user, NotificationInterfase $notification): bool
35
    {
36
        $from = Di::getDefault()->getUserData();
37
38
        $notification->setTo($user);
39
        $notification->setFrom($from);
40
41
        return $notification->process();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $notification->process() returns the type boolean which is incompatible with the documented return type void.
Loading history...
42
    }
43
}
44