Code Duplication    Length = 23-23 lines in 2 locations

src/V1/OmsApi.php 1 location

@@ 69-91 (lines=23) @@
66
    /**
67
     * @throws OmsRequestErrorException
68
     */
69
    private function request(string $token, string $method, string $uri, array $query = [], $body = null): string
70
    {
71
        $options = [
72
            RequestOptions::BODY => $body,
73
            RequestOptions::HEADERS => [
74
                'Content-Type' => 'application/json',
75
                'clientToken' => $token,
76
            ],
77
            RequestOptions::QUERY => $query,
78
            RequestOptions::HTTP_ERRORS => true,
79
        ];
80
81
        $uri = ltrim($uri, '/');
82
83
        try {
84
            $result = $this->client->request($method, $uri, $options);
85
        } catch (\Throwable $exception) {
86
            /* @noinspection PhpUnhandledExceptionInspection */
87
            throw $this->handleRequestException($exception);
88
        }
89
90
        return (string) $result->getBody();
91
    }
92
93
    private function handleRequestException(\Throwable $exception): \Throwable
94
    {

src/V2/OmsApi.php 1 location

@@ 84-106 (lines=23) @@
81
    /**
82
     * @throws OmsRequestErrorException
83
     */
84
    private function request(string $token, string $method, string $uri, array $query = [], $body = null): string
85
    {
86
        $options = [
87
            RequestOptions::BODY => $body,
88
            RequestOptions::HEADERS => [
89
                'Content-Type' => 'application/json',
90
                'clientToken' => $token,
91
            ],
92
            RequestOptions::QUERY => $query,
93
            RequestOptions::HTTP_ERRORS => true,
94
        ];
95
96
        $uri = ltrim($uri, '/');
97
98
        try {
99
            $result = $this->client->request($method, $uri, $options);
100
        } catch (\Throwable $exception) {
101
            /* @noinspection PhpUnhandledExceptionInspection */
102
            throw $this->handleRequestException($exception);
103
        }
104
105
        return (string) $result->getBody();
106
    }
107
108
    private function handleRequestException(\Throwable $exception): \Throwable
109
    {