Sentry::getProjects()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 95

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 95
rs 8.109
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Integrations\Connectors\Sentry;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Log;
7
use App\Models\User;
8
use Integrations\Connectors\Connector;
9
10
class Sentry extends Connector
11
{
12
    public static $ID = 16;
13
    public $url = 'sentry.io';
14
15
    protected function getConnection($token = false)
16
    {
17
        return $this;
18
    }
19
20
    public function getProjects()
21
    {
22
        //HTTP/1.1
23
        //Authorization: Bearer <token>
24
        return $this->get($this->url.'/api/0/projects/');
25
        /**
26
 * Resposta
27
         * [
28
         *  {
29
         *      "avatar": {
30
         *      "avatarType": "letter_avatar", 
31
         *      "avatarUuid": null
32
         *      }, 
33
         *      "color": "#bf6e3f", 
34
         *      "dateCreated": "2018-11-06T21:20:08.064Z", 
35
         *      "features": [
36
         *      "servicehooks", 
37
         *      "sample-events", 
38
         *      "data-forwarding", 
39
         *      "rate-limits", 
40
         *      "minidump"
41
         *      ], 
42
         *      "firstEvent": null, 
43
         *      "hasAccess": true, 
44
         *      "id": "4", 
45
         *      "isBookmarked": false, 
46
         *      "isInternal": false, 
47
         *      "isMember": true, 
48
         *      "isPublic": false, 
49
         *      "name": "The Spoiled Yoghurt", 
50
         *      "organization": {
51
         *      "avatar": {
52
         *          "avatarType": "letter_avatar", 
53
         *          "avatarUuid": null
54
         *      }, 
55
         *      "dateCreated": "2018-11-06T21:19:55.101Z", 
56
         *      "id": "2", 
57
         *      "isEarlyAdopter": false, 
58
         *      "name": "The Interstellar Jurisdiction", 
59
         *      "require2FA": false, 
60
         *      "slug": "the-interstellar-jurisdiction", 
61
         *      "status": {
62
         *          "id": "active", 
63
         *          "name": "active"
64
         *      }
65
         *      }, 
66
         *      "platform": null, 
67
         *      "slug": "the-spoiled-yoghurt", 
68
         *      "status": "active"
69
         *  }, 
70
         *  {
71
         *      "avatar": {
72
         *      "avatarType": "letter_avatar", 
73
         *      "avatarUuid": null
74
         *      }, 
75
         *      "color": "#bf5b3f", 
76
         *      "dateCreated": "2018-11-06T21:19:58.536Z", 
77
         *      "features": [
78
         *      "releases", 
79
         *      "sample-events", 
80
         *      "minidump", 
81
         *      "servicehooks", 
82
         *      "rate-limits", 
83
         *      "data-forwarding"
84
         *      ], 
85
         *      "firstEvent": null, 
86
         *      "hasAccess": true, 
87
         *      "id": "3", 
88
         *      "isBookmarked": false, 
89
         *      "isInternal": false, 
90
         *      "isMember": true, 
91
         *      "isPublic": false, 
92
         *      "name": "Prime Mover", 
93
         *      "organization": {
94
         *      "avatar": {
95
         *          "avatarType": "letter_avatar", 
96
         *          "avatarUuid": null
97
         *      }, 
98
         *      "dateCreated": "2018-11-06T21:19:55.101Z", 
99
         *      "id": "2", 
100
         *      "isEarlyAdopter": false, 
101
         *      "name": "The Interstellar Jurisdiction", 
102
         *      "require2FA": false, 
103
         *      "slug": "the-interstellar-jurisdiction", 
104
         *      "status": {
105
         *          "id": "active", 
106
         *          "name": "active"
107
         *      }
108
         *      }, 
109
         *      "platform": null, 
110
         *      "slug": "prime-mover", 
111
         *      "status": "active"
112
         *  }, 
113
         */
114
    }
115
}
116