Code Duplication    Length = 23-23 lines in 2 locations

src/V1/OmsApi.php 1 location

@@ 52-74 (lines=23) @@
49
    /**
50
     * @throws OmsClientExceptionInterface
51
     */
52
    private function request(string $token, string $method, string $uri, array $query = [], $body = null): string
53
    {
54
        $options = [
55
            RequestOptions::BODY => $body,
56
            RequestOptions::HEADERS => [
57
                'Content-Type' => 'application/json',
58
                'clientToken' => $token,
59
            ],
60
            RequestOptions::QUERY => $query,
61
            RequestOptions::HTTP_ERRORS => true,
62
        ];
63
64
        $uri = ltrim($uri, '/');
65
66
        try {
67
            $result = $this->client->request($method, $uri, $options);
68
        } catch (Throwable $exception) {
69
            /* @noinspection PhpUnhandledExceptionInspection */
70
            throw $this->handleRequestException($exception);
71
        }
72
73
        return (string)$result->getBody();
74
    }
75
76
    private function handleRequestException(Throwable $exception): OmsClientExceptionInterface
77
    {

src/V2/OmsApi.php 1 location

@@ 58-80 (lines=23) @@
55
    /**
56
     * @throws OmsRequestErrorException
57
     */
58
    private function request(string $token, string $method, string $uri, array $query = [], $body = null): string
59
    {
60
        $options = [
61
            RequestOptions::BODY => $body,
62
            RequestOptions::HEADERS => [
63
                'Content-Type' => 'application/json',
64
                'clientToken' => $token,
65
            ],
66
            RequestOptions::QUERY => $query,
67
            RequestOptions::HTTP_ERRORS => true,
68
        ];
69
70
        $uri = ltrim($uri, '/');
71
72
        try {
73
            $result = $this->client->request($method, $uri, $options);
74
        } catch (Throwable $exception) {
75
            /* @noinspection PhpUnhandledExceptionInspection */
76
            throw $this->handleRequestException($exception);
77
        }
78
79
        return (string)$result->getBody();
80
    }
81
82
    private function handleRequestException(Throwable $exception): OmsClientExceptionInterface
83
    {