Code Duplication    Length = 12-16 lines in 2 locations

app/Services/MediaMetadataService.php 2 locations

@@ 48-59 (lines=12) @@
45
     *
46
     * @param string $destination The destination path. Automatically generated if empty.
47
     */
48
    public function writeAlbumCover(Album $album, string $binaryData, string $extension, string $destination = ''): void
49
    {
50
        try {
51
            $extension = trim(strtolower($extension), '. ');
52
            $destination = $destination ?: $this->generateAlbumCoverPath($extension);
53
            file_put_contents($destination, $binaryData);
54
55
            $album->update(['cover' => basename($destination)]);
56
        } catch (Exception $e) {
57
            $this->logger->error($e);
58
        }
59
    }
60
61
    /**
62
     * Download a copy of the artist image.
@@ 75-90 (lines=16) @@
72
     *
73
     * @param string $destination The destination path. Automatically generated if empty.
74
     */
75
    public function writeArtistImage(
76
        Artist $artist,
77
        string $binaryData,
78
        string $extension,
79
        string $destination = ''
80
    ): void {
81
        try {
82
            $extension = trim(strtolower($extension), '. ');
83
            $destination = $destination ?: $this->generateArtistImagePath($extension);
84
            file_put_contents($destination, $binaryData);
85
86
            $artist->update(['image' => basename($destination)]);
87
        } catch (Exception $e) {
88
            $this->logger->error($e);
89
        }
90
    }
91
92
    /**
93
     * Generate a random path for an album cover image.