Code Duplication    Length = 17-18 lines in 3 locations

src/Console/Commands/PublishDeleteAssignment.php 1 location

@@ 81-97 (lines=17) @@
78
     *
79
     * @return array|mixed
80
     */
81
    protected function delete_assignment()
82
    {
83
        $uri = str_replace('{assignment}', $this->assignment, config('forge-publish.update_assignment_uri'));
84
        $url = config('forge-publish.url') . $uri;
85
        try {
86
            $response = $this->http->delete($url, [
87
                'headers' => [
88
                    'X-Requested-With' => 'XMLHttpRequest',
89
                    'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN')
90
                ]
91
            ]);
92
        } catch (\Exception $e) {
93
            $this->error('And error occurs connecting to the api url: ' . $url);
94
            $this->error('Status code: ' . $e->getResponse()->getStatusCode() . ' | Reason : ' . $e->getResponse()->getReasonPhrase());
95
            return [];
96
        }
97
    }
98
99
    /**
100
     * Abort command execution.

src/Console/Commands/PublishShowAssignment.php 1 location

@@ 105-121 (lines=17) @@
102
     *
103
     * @return array|mixed
104
     */
105
    protected function fetch_assignment()
106
    {
107
        $uri = str_replace('{assignment}', $this->assignment, config('forge-publish.show_assignment_uri'));
108
        $url = config('forge-publish.url') . $uri;
109
        try {
110
            $response = $this->http->get($url, [
111
                'headers' => [
112
                    'X-Requested-With' => 'XMLHttpRequest',
113
                    'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN')
114
                ]
115
            ]);
116
        } catch (\Exception $e) {
117
            $this->error('And error occurs connecting to the api url: ' . $url);
118
            $this->error('Status code: ' . $e->getResponse()->getStatusCode() . ' | Reason : ' . $e->getResponse()->getReasonPhrase());
119
        }
120
        return json_decode((string) $response->getBody());
121
    }
122
123
    /**
124
     * Abort command execution.

src/Console/Commands/Traits/ItFetchesServers.php 1 location

@@ 15-32 (lines=18) @@
12
    /**
13
     * Fetch servers
14
     */
15
    protected function fetchServers()
16
    {
17
        $url = config('forge-publish.url') . config('forge-publish.user_servers_uri');
18
        try {
19
            $response = $this->http->get($url, [
20
                'headers' => [
21
                    'X-Requested-With' => 'XMLHttpRequest',
22
                    'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN')
23
                ]
24
            ]);
25
        } catch (\Exception $e) {
26
            $this->error('And error occurs connecting to the api url: ' . $url);
27
            dd($e);
28
            $this->error('Status code: ' . $e->getResponse()->getStatusCode() . ' | Reason : ' . $e->getResponse()->getReasonPhrase());
29
            return [];
30
        }
31
        return json_decode((string) $response->getBody());
32
    }
33
34
    /**
35
     * Get forge id server from server name.