NotificationSubscriber::handleEvent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of Jitamin.
5
 *
6
 * Copyright (C) Jitamin Team
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Jitamin\Bus\Subscriber;
13
14
use Jitamin\Bus\Event\GenericEvent;
15
use Jitamin\Model\CommentModel;
16
use Jitamin\Model\SubtaskModel;
17
use Jitamin\Model\TaskFileModel;
18
use Jitamin\Model\TaskLinkModel;
19
use Jitamin\Model\TaskModel;
20
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
21
22
/**
23
 * Notification Subscriber.
24
 */
25
class NotificationSubscriber extends BaseSubscriber implements EventSubscriberInterface
26
{
27
    /**
28
     * Get event listeners.
29
     *
30
     * @static
31
     *
32
     * @return array
33
     */
34
    public static function getSubscribedEvents()
35
    {
36
        return [
37
            TaskModel::EVENT_USER_MENTION      => 'handleEvent',
38
            TaskModel::EVENT_CREATE            => 'handleEvent',
39
            TaskModel::EVENT_UPDATE            => 'handleEvent',
40
            TaskModel::EVENT_CLOSE             => 'handleEvent',
41
            TaskModel::EVENT_OPEN              => 'handleEvent',
42
            TaskModel::EVENT_MOVE_COLUMN       => 'handleEvent',
43
            TaskModel::EVENT_MOVE_POSITION     => 'handleEvent',
44
            TaskModel::EVENT_MOVE_SWIMLANE     => 'handleEvent',
45
            TaskModel::EVENT_ASSIGNEE_CHANGE   => 'handleEvent',
46
            SubtaskModel::EVENT_CREATE         => 'handleEvent',
47
            SubtaskModel::EVENT_UPDATE         => 'handleEvent',
48
            SubtaskModel::EVENT_DELETE         => 'handleEvent',
49
            CommentModel::EVENT_CREATE         => 'handleEvent',
50
            CommentModel::EVENT_UPDATE         => 'handleEvent',
51
            CommentModel::EVENT_DELETE         => 'handleEvent',
52
            CommentModel::EVENT_USER_MENTION   => 'handleEvent',
53
            TaskFileModel::EVENT_CREATE        => 'handleEvent',
54
            TaskLinkModel::EVENT_CREATE_UPDATE => 'handleEvent',
55
            TaskLinkModel::EVENT_DELETE        => 'handleEvent',
56
        ];
57
    }
58
59
    /**
60
     * Handle the event.
61
     *
62
     * @param GenericEvent $event
63
     * @param string       $eventName
64
     */
65
    public function handleEvent(GenericEvent $event, $eventName)
66
    {
67
        $this->logger->debug('Subscriber executed: '.__METHOD__);
0 ignored issues
show
Documentation introduced by
The property logger does not exist on object<Jitamin\Bus\Subsc...NotificationSubscriber>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
68
        $this->queueManager->push($this->notificationJob->withParams($event, $eventName));
0 ignored issues
show
Documentation introduced by
The property queueManager does not exist on object<Jitamin\Bus\Subsc...NotificationSubscriber>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property notificationJob does not exist on object<Jitamin\Bus\Subsc...NotificationSubscriber>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
69
    }
70
}
71