WebhooksController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 3
c 6
b 0
f 0
lcom 0
cbo 0
dl 0
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 15 3
1
<?php namespace Bedard\Webhooks\Http;
2
3
use Request;
4
use Response;
5
use Exception;
6
use Bedard\Webhooks\Models\Hook;
7
use Illuminate\Routing\Controller;
8
9
class WebhooksController extends Controller
10
{
11
12
    /**
13
     * Execute a webhook
14
     *
15
     * @param  string   $token
16
     * @return Response
17
     */
18
    public function execute($token)
19
    {
20
        try {
21
            // If no webhook was found, return a 404
22
            if (!$hook = Hook::findByTokenAndMethod($token, Request::method())) {
23
                return Response::make(e(trans('bedard.webhooks::lang.responses.not_found')), 404);
24
            }
25
26
            // Otherwise queue the script for execution, and return a 200
27
            $hook->queueScript();
28
            return Response::make(e(trans('bedard.webhooks::lang.responses.success')), 200);
29
        } catch (Exception $e) {
30
            return Response::make(e(trans('bedard.webhooks::lang.responses.failed')), 500);
31
        }
32
    }
33
}
34