Code Duplication    Length = 10-16 lines in 2 locations

src/Connectors/Linkedin.php 1 location

@@ 26-41 (lines=16) @@
23
24
        // dd($json_result);
25
26
        if (isset($json_result['status']) && $json_result['status'] != 200) {
27
            $msg = 'Error accessing LinkedIn API. Status: %s. Error code: %s. Message: %s';
28
            $msg = sprintf(
29
                $msg,
30
                $json_result['status'],
31
                $json_result['errorCode'],
32
                $json_result['message']
33
            );
34
35
            if ($json_result['status'] == '401') {
36
                throw new ExpiredTokenException($msg);
37
            } else {
38
                throw new GenericPostingException($msg);
39
            }
40
41
        }
42
43
        return $result;
44
    }

src/Connectors/LinkedinPage.php 1 location

@@ 48-57 (lines=10) @@
45
        // The response comes in JSON
46
        $json_result = json_decode($result, true);
47
48
        if (isset($json_result['status']) && $json_result['status'] != 200) {
49
            $msg = "Error posting to Linkedin page. Error code from Linkedin: %s. Error message from Linkedin: %s";
50
            $msg = sprintf($msg, $json_result['errorCode'], $json_result['message']);
51
52
            if ($json_result['status'] == '401') {
53
                throw new ExpiredTokenException($msg);
54
            } else {
55
                throw new GenericPostingException($msg, $json_result['status']);
56
            }
57
        }
58
59
        $response = new Response;
60
        $response->setRawResponse(json_encode($result));