ProjectModificationDateSubscriber   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 13 1
A execute() 0 5 1
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\TaskModel;
16
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
17
18
/**
19
 * Project modification date  Subscriber.
20
 */
21
class ProjectModificationDateSubscriber extends BaseSubscriber implements EventSubscriberInterface
22
{
23
    /**
24
     * Get event listeners.
25
     *
26
     * @static
27
     *
28
     * @return array
29
     */
30
    public static function getSubscribedEvents()
31
    {
32
        return [
33
            TaskModel::EVENT_CREATE_UPDATE   => 'execute',
34
            TaskModel::EVENT_CLOSE           => 'execute',
35
            TaskModel::EVENT_OPEN            => 'execute',
36
            TaskModel::EVENT_MOVE_SWIMLANE   => 'execute',
37
            TaskModel::EVENT_MOVE_COLUMN     => 'execute',
38
            TaskModel::EVENT_MOVE_POSITION   => 'execute',
39
            TaskModel::EVENT_MOVE_PROJECT    => 'execute',
40
            TaskModel::EVENT_ASSIGNEE_CHANGE => 'execute',
41
        ];
42
    }
43
44
    /**
45
     * Handle the event.
46
     *
47
     * @param GenericEvent $event
48
     */
49
    public function execute(GenericEvent $event)
50
    {
51
        $this->logger->debug('Subscriber executed: '.__METHOD__);
0 ignored issues
show
Documentation introduced by
The property logger does not exist on object<Jitamin\Bus\Subsc...ficationDateSubscriber>. 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...
52
        $this->projectModel->updateModificationDate($event['task']['project_id']);
0 ignored issues
show
Documentation introduced by
The property projectModel does not exist on object<Jitamin\Bus\Subsc...ficationDateSubscriber>. 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...
53
    }
54
}
55