Code Duplication    Length = 25-25 lines in 2 locations

src/Adapter.php 2 locations

@@ 75-99 (lines=25) @@
72
     *
73
     * @return array|bool
74
     */
75
    public function write($path, $contents, Config $config)
76
    {
77
        $tmpfname = $this->writeTempFile($contents);
78
79
        try {
80
            $response = Cosapi::upload($this->getBucket(), $tmpfname, $path,
81
                                        null, null, $config->get('insertOnly', 1));
82
83
            $this->deleteTempFile($tmpfname);
84
85
            $response = $this->normalizeResponse($response);
86
87
            if (false === $response) {
88
                return false;
89
            }
90
91
            $this->setContentType($path, $contents);
92
        } catch (RuntimeException $exception) {
93
            $this->deleteTempFile($tmpfname);
94
95
            throw $exception;
96
        }
97
98
        return $response;
99
    }
100
101
    /**
102
     * @param string   $path
@@ 137-161 (lines=25) @@
134
     *
135
     * @return array|bool
136
     */
137
    public function update($path, $contents, Config $config)
138
    {
139
        $tmpfname = $this->writeTempFile($contents);
140
141
        try {
142
            $response = Cosapi::upload($this->getBucket(), $tmpfname, $path,
143
                                        null, null, $config->get('insertOnly', 0));
144
145
            $this->deleteTempFile($tmpfname);
146
147
            $response = $this->normalizeResponse($response);
148
149
            if (false === $response) {
150
                return false;
151
            }
152
153
            $this->setContentType($path, $contents);
154
        } catch (RuntimeException $exception) {
155
            $this->deleteTempFile($tmpfname);
156
157
            throw $exception;
158
        }
159
160
        return $response;
161
    }
162
163
    /**
164
     * @param string   $path