Code Duplication    Length = 11-12 lines in 2 locations

src/KeyManager.php 2 locations

@@ 45-55 (lines=11) @@
42
     * @param int $client_id
43
     * @return \Illuminate\Http\JsonResponse
44
     */
45
    public function getPrivateKey(int $client_id): JsonResponse
46
    {
47
        $client = Client::with('apiCredential')->where('id', $client_id)->first();
48
49
        if (! $client) {
50
            return $this->error("No client found with id $client_id");
51
        }
52
53
        return $this->success('Key retrieved successfully', ['key' => $client->apiCredential->private_key]);
54
    }
55
56
    /**
57
     * Change Client's public and private keys.
58
     *
@@ 62-73 (lines=12) @@
59
     * @param int $client_id
60
     * @return \Illuminate\Http\JsonResponse
61
     */
62
    public function changeKeys(int $client_id): JsonResponse
63
    {
64
        $key = ApiCredential::where('key_client_id', $client_id)->first();
65
66
        if (! $key) {
67
            return $this->error('Client information not found');
68
        }
69
70
        $key->update(ApiCredential::generateKeyPairArray());
71
72
        return $this->success('Api Keys successfully changed', ['key' => $key->private_key]);
73
    }
74
75
    /**
76
     * Suspend Client's Account.