EmailNotifications::shouldHandle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 1
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Canvas\Handlers;
4
5
use Namshi\Notificator\Notification\Handler\HandlerInterface;
0 ignored issues
show
Bug introduced by
The type Namshi\Notificator\Notif...andler\HandlerInterface 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...
6
use Canvas\Contracts\Notifications\EmailNotificationsInterface as EmailNotificationsContract;
0 ignored issues
show
Bug introduced by
The type Canvas\Contracts\Notific...lNotificationsInterface 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...
7
use Namshi\Notificator\NotificationInterface;
0 ignored issues
show
Bug introduced by
The type Namshi\Notificator\NotificationInterface 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...
8
use Phalcon\Di;
9
10
class EmailNotifications implements HandlerInterface
11
{
12
    /**
13
     * Stablishes type of handler.
14
     */
15
    public function shouldHandle(NotificationInterface $notification)
16
    {
17
        return $notification instanceof EmailNotificationsContract;
18
    }
19
20
    /**
21
     * Handles actions to take depending of notifications.
22
     * @param NotificationInterface $notification
23
     */
24
    public function handle(NotificationInterface $notification)
25
    {
26
        /**
27
         * Lets log the email.
28
         */
29
        Di::getDefault()->getLog()->info(json_encode($notification->assemble()));
30
31
        $content = $notification->assemble()->template;
32
33
        /**
34
         * Lets send the email.
35
         */
36
        Di::getDefault()->getMail()
37
            ->to('[email protected]')
38
            ->subject('Test subject')
39
            ->content($content)
40
            ->sendNow();
41
    }
42
}
43