Completed
Push — master ( 8b2631...238be2 )
by Dragos
11:46
created

SubscriptionController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
c 2
b 0
f 1
lcom 1
cbo 6
dl 0
loc 67
ccs 12
cts 12
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A createdAction() 0 6 1
A changedAction() 0 6 1
A canceledAction() 0 6 1
A closedAction() 0 6 1
A reactivatedAction() 0 6 1
1
<?php
2
3
namespace Speicher210\FastbillBundle\Controller\Notification;
4
5
use Speicher210\Fastbill\Api\Model\Notification\Subscription\SubscriptionCanceledNotification;
6
use Speicher210\Fastbill\Api\Model\Notification\Subscription\SubscriptionChangedNotification;
7
use Speicher210\Fastbill\Api\Model\Notification\Subscription\SubscriptionClosedNotification;
8
use Speicher210\Fastbill\Api\Model\Notification\Subscription\SubscriptionCreatedNotification;
9
use Speicher210\Fastbill\Api\Model\Notification\Subscription\SubscriptionReactivatedNotification;
10
use Speicher210\FastbillBundle\Event\SubscriptionCanceledEvent;
11
use Speicher210\FastbillBundle\Event\SubscriptionChangedEvent;
12
use Speicher210\FastbillBundle\Event\SubscriptionClosedEvent;
13
use Speicher210\FastbillBundle\Event\SubscriptionCreatedEvent;
14
use Speicher210\FastbillBundle\Event\SubscriptionReactivatedEvent;
15
use Symfony\Component\HttpFoundation\Request;
16
use Symfony\Component\HttpFoundation\Response;
17
18
/**
19
 * Controller for subscriptions notifications.
20
 */
21
class SubscriptionController extends AbstractController
22
{
23
    /**
24
     * Action when a subscription is created.
25
     *
26
     * @param Request $request The made request.
27
     * @return Response
28 12
     */
29
    public function createdAction(Request $request)
30 12
    {
31
        $event = new SubscriptionCreatedEvent();
32 12
33
        return $this->handleNotification($request, $event, SubscriptionCreatedNotification::class);
34
    }
35
36
    /**
37
     * Action when a subscription is changed.
38
     *
39
     * @param Request $request The made request.
40
     * @return Response
41 3
     */
42
    public function changedAction(Request $request)
43 3
    {
44
        $event = new SubscriptionChangedEvent();
45 3
46
        return $this->handleNotification($request, $event, SubscriptionChangedNotification::class);
47
    }
48
49
    /**
50
     * Action when a subscription is canceled.
51
     *
52
     * @param Request $request The made request.
53
     * @return Response
54 3
     */
55
    public function canceledAction(Request $request)
56 3
    {
57
        $event = new SubscriptionCanceledEvent();
58 3
59
        return $this->handleNotification($request, $event, SubscriptionCanceledNotification::class);
60
    }
61
62
    /**
63
     * Action when a subscription is closed.
64
     *
65
     * @param Request $request The made request.
66
     * @return Response
67 3
     */
68
    public function closedAction(Request $request)
69 3
    {
70
        $event = new SubscriptionClosedEvent();
71 3
72
        return $this->handleNotification($request, $event, SubscriptionClosedNotification::class);
73
    }
74
75
    /**
76
     * Action when a subscription is reactivated.
77
     *
78
     * @param Request $request The made request.
79
     * @return Response
80
     */
81
    public function reactivatedAction(Request $request)
82
    {
83
        $event = new SubscriptionReactivatedEvent();
84
85
        return $this->handleNotification($request, $event, SubscriptionReactivatedNotification::class);
86
    }
87
}
88