Failed Conditions
Push — master ( f0f3b5...42ea38 )
by Maximo
57s queued 10s
created

SubscriptionMiddleware::call()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Canvas\Middleware;
6
7
use Phalcon\Mvc\Micro;
8
use Canvas\Http\Exception\UnauthorizedException;
9
use Canvas\Models\Subscription;
10
11
/**
12
 * Class AuthenticationMiddleware.
13
 *
14
 * @package Niden\Middleware
15
 */
16
class SubscriptionMiddleware extends TokenBase
17
{
18
    /**
19
     * Call me.
20
     *
21
     * @param Micro $api
22
     * @todo need to check section for auth here
23
     * @return bool
24
     */
25
    public function call(Micro $api)
0 ignored issues
show
Coding Style introduced by
function call() does not seem to conform to the naming convention (^(?:is|has|should|may|supports)).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
26
    {
27
        if ($api->getDI()->has('userData')) {
28
            $user = $api->getDI()->getUserData();
29
30
            if (!Subscription::getByDefaultCompany($user)->active()) {
31
                throw new UnauthorizedException('Subscription expired, Verify Payment');
32
            }
33
        }
34
35
        return true;
36
    }
37
}
38