Failed Conditions
Pull Request — master (#327)
by Rafael
03:04
created

Sources   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 86
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isApple() 0 4 1
A initialize() 0 4 1
A getSource() 0 4 1
A validateAppleUser() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Canvas\Models;
6
7
use Phalcon\Di;
8
use Canvas\Exception\ModelException;
9
use Baka\ASDecoder;
10
use Canvas\Http\Exception\InternalServerErrorException;
11
12
13
/**
14
 * Class Resources
15
 *
16
 * @package Canvas\Models
17
 *
18
 * @property \Phalcon\Di $di
19
 */
20
class Sources extends AbstractModel
21
{
22
    /**
23
     *
24
     * @var integer
25
     */
26
    public $id;
27
28
    /**
29
     *
30
     * @var string
31
     */
32
    public $title;
33
34
    /**
35
     *
36
     * @var string
37
     */
38
    public $url;
39
40
    /**
41
     *
42
     * @var integer
43
     */
44
    public $language_id;
0 ignored issues
show
Coding Style introduced by
$language_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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...
45
46
    /**
47
     *
48
     * @var string
49
     */
50
    public $created_at;
0 ignored issues
show
Coding Style introduced by
$created_at does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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...
51
52
    /**
53
     *
54
     * @var string
55
     */
56
    public $updated_at;
0 ignored issues
show
Coding Style introduced by
$updated_at does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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...
57
58
    /**
59
     *
60
     * @var integer
61
     */
62
    public $is_deleted;
0 ignored issues
show
Coding Style introduced by
$is_deleted does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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...
63
64
    /**
65
     * Initialize method for model.
66
     */
67
    public function initialize()
68
    {
69
        $this->setSource('sources');
70
    }
71
72
    /**
73
     * Returns table name mapped in the model.
74
     *
75
     * @return string
76
     */
77
    public function getSource(): string
78
    {
79
        return 'sources';
80
    }
81
82
    /**
83
     * Verify if source is Apple
84
     */
85
    public function isApple(): bool
86
    {
87
        return $this->title == 'apple';
88
    }
89
90
    /**
91
     * Validate Apple User.
92
     * @param string $identityToken
93
     * @return object
94
     */
95
    public function validateAppleUser(string $identityToken): object
96
    {
97
        $appleUserInfo = ASDecoder::getAppleSignInPayload($identityToken);
98
99
        if (!is_object($appleUserInfo)) {
100
            throw new InternalServerErrorException('Apple user not valid');
101
        }
102
103
        return $appleUserInfo;
104
    }
105
}
106