Passed
Push — master ( 3a61d1...066a33 )
by Chris
14:55
created

IncomingWebhookController::fireEventFor()   B

Complexity

Conditions 8
Paths 8

Size

Total Lines 26
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 24
c 1
b 0
f 0
dl 0
loc 26
rs 8.4444
cc 8
nc 8
nop 2
1
<?php
2
3
namespace Meema\MediaRecognition\Http\Controllers;
4
5
use Aws\Sns\Message;
6
use Illuminate\Routing\Controller;
7
8
class IncomingWebhookController extends Controller
9
{
10
    public function __construct()
11
    {
12
        $this->middleware('verify-signature');
13
    }
14
15
    /**
16
     * @throws \Exception
17
     */
18
    public function __invoke()
19
    {
20
        $message = json_decode(Message::fromRawPostData()['Message'], true);
21
        $detail = $message['detail'];
22
        $status = $detail['status'];
23
24
        try {
25
            $this->fireEventFor($status, $message);
26
        } catch (\Exception $e) {
27
            throw new \Exception($e);
28
        }
29
    }
30
31
    /**
32
     * @param $status
33
     * @param $message
34
     * @throws \Exception
35
     */
36
    public function fireEventFor($status, $message)
37
    {
38
        switch ($status) {
39
            case 'PROGRESSING':
40
                event(new ConversionIsProgressing($message));
0 ignored issues
show
Bug introduced by
The type Meema\MediaRecognition\H...ConversionIsProgressing 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...
41
                break;
42
            case 'INPUT_INFORMATION':
43
                event(new ConversionHasInputInformation($message));
0 ignored issues
show
Bug introduced by
The type Meema\MediaRecognition\H...sionHasInputInformation 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...
44
                break;
45
            case 'COMPLETE':
46
                event(new ConversionHasCompleted($message));
0 ignored issues
show
Bug introduced by
The type Meema\MediaRecognition\H...\ConversionHasCompleted 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...
47
                break;
48
            case 'STATUS_UPDATE':
49
                event(new ConversionHasStatusUpdate($message));
0 ignored issues
show
Bug introduced by
The type Meema\MediaRecognition\H...nversionHasStatusUpdate 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...
50
                break;
51
            case 'NEW_WARNING':
52
                event(new ConversionHasNewWarning($message));
0 ignored issues
show
Bug introduced by
The type Meema\MediaRecognition\H...ConversionHasNewWarning 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...
53
                break;
54
            case 'QUEUE_HOP':
55
                event(new ConversionQueueHop($message));
0 ignored issues
show
Bug introduced by
The type Meema\MediaRecognition\H...lers\ConversionQueueHop 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...
56
                break;
57
            case 'ERROR':
58
                event(new ConversionHasError($message));
0 ignored issues
show
Bug introduced by
The type Meema\MediaRecognition\H...lers\ConversionHasError 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...
59
                break;
60
            default:
61
                throw new \Exception();
62
        }
63
    }
64
}
65