Code Duplication    Length = 24-24 lines in 2 locations

src/Adapter.php 2 locations

@@ 68-91 (lines=24) @@
65
     *
66
     * @return bool
67
     */
68
    public function write($path, $contents, Config $config)
69
    {
70
        $tmpfname = $this->writeTempFile($contents);
71
72
        try {
73
            $response = $this->normalizeResponse(
74
                Cosapi::upload($this->getBucket(), $tmpfname, $path)
75
            );
76
77
            $this->deleteTempFile($tmpfname);
78
79
            $this->setContentType($path, $contents);
80
        } catch (RuntimeException $exception) {
81
            $this->deleteTempFile($tmpfname);
82
83
            if ($exception->getCode() == -4018) {
84
                return $this->getMetadata($path);
85
            }
86
87
            throw $exception;
88
        }
89
90
        return $response;
91
    }
92
93
    /**
94
     * @param string   $path
@@ 128-151 (lines=24) @@
125
     *
126
     * @return bool
127
     */
128
    public function update($path, $contents, Config $config)
129
    {
130
        $tmpfname = $this->writeTempFile($contents);
131
132
        try {
133
            $response = $this->normalizeResponse(
134
                Cosapi::upload($this->getBucket(), $tmpfname, $path, null, null, 0)
135
            );
136
137
            $this->deleteTempFile($tmpfname);
138
139
            $this->setContentType($path, $contents);
140
        } catch (RuntimeException $exception) {
141
            $this->deleteTempFile($tmpfname);
142
143
            if ($exception->getCode() == -4018) {
144
                return $this->getMetadata($path);
145
            }
146
147
            throw $exception;
148
        }
149
150
        return $response;
151
    }
152
153
    /**
154
     * @param string   $path