Code Duplication    Length = 10-14 lines in 3 locations

eZ/Publish/Core/IO/IOMetadataHandler/LegacyDFSCluster.php 3 locations

@@ 100-113 (lines=14) @@
97
     *
98
     * @param string $spiBinaryFileId
99
     */
100
    public function delete($spiBinaryFileId)
101
    {
102
        $path = $this->addPrefix($spiBinaryFileId);
103
104
        // Unlike the legacy cluster, the file is directly deleted. It was inherited from the DB cluster anyway
105
        $stmt = $this->db->prepare('DELETE FROM ezdfsfile WHERE name_hash LIKE :name_hash');
106
        $stmt->bindValue('name_hash', md5($path));
107
        $stmt->execute();
108
109
        if ($stmt->rowCount() != 1) {
110
            // Is this really necessary ?
111
            throw new BinaryFileNotFoundException($path);
112
        }
113
    }
114
115
    /**
116
     * Loads and returns metadata for $spiBinaryFileId.
@@ 152-161 (lines=10) @@
149
     *
150
     * @return bool
151
     */
152
    public function exists($spiBinaryFileId)
153
    {
154
        $path = $this->addPrefix($spiBinaryFileId);
155
156
        $stmt = $this->db->prepare('SELECT name FROM ezdfsfile WHERE name_hash LIKE ? and mtime > 0 and expired != 1');
157
        $stmt->bindValue(1, md5($path));
158
        $stmt->execute();
159
160
        return ($stmt->rowCount() == 1);
161
    }
162
163
    /**
164
     * @param SPIBinaryFileCreateStruct $binaryFileCreateStruct
@@ 224-237 (lines=14) @@
221
        return isset($this->urlDecorator) ? $this->urlDecorator->undecorate($prefixedId) : $prefixedId;
222
    }
223
224
    public function getMimeType($spiBinaryFileId)
225
    {
226
        $stmt = $this->db->prepare('SELECT * FROM ezdfsfile WHERE name_hash LIKE ? AND expired != 1 AND mtime > 0');
227
        $stmt->bindValue(1, md5($this->addPrefix($spiBinaryFileId)));
228
        $stmt->execute();
229
230
        if ($stmt->rowCount() == 0) {
231
            throw new BinaryFileNotFoundException($spiBinaryFileId);
232
        }
233
234
        $row = $stmt->fetch(\PDO::FETCH_ASSOC);
235
236
        return $row['datatype'];
237
    }
238
239
    public function deleteDirectory($spiPath)
240
    {