Code Duplication    Length = 19-23 lines in 2 locations

src/storage/storage/FilesStorage.php 1 location

@@ 83-101 (lines=19) @@
80
	 *
81
	 * @throws \Exception
82
	 */
83
	public function deleteFileByName($filename)
84
	{
85
		$destinationPath = $this->getDestinationPath();
86
		$destination = $destinationPath . '/' . $filename;
87
88
		if (file_exists($destination)) {
89
			$files = $this->getFiles();
90
			foreach ($files as $key => $file) {
91
				if ($file->file == $filename) {
92
					unlink($destination);
93
					unset($files[$key]);
94
				}
95
			}
96
97
			$files = array_values($files);
98
			$this->repository->files = $files;
99
			$this->save();
100
		}
101
	}
102
103
	/**
104
	 * @param $a

src/storage/storage/ImagesStorage.php 1 location

@@ 74-96 (lines=23) @@
71
     * Delete image by name
72
     * @param $filename
73
     */
74
    public function deleteImageByName($filename)
75
    {
76
        $destinationPath = $this->getDestinationPath();
77
78
        $images = $this->getImages();
79
80
        foreach ($images as $key => $image) {
81
            if ($image->file == $filename) {
82
                foreach ($image->set as $imageSetFilename) {
83
                    $destination = $destinationPath . '/' . $imageSetFilename;
84
                    if (file_exists($destination)) {
85
                        unlink($destination);
86
                    } else {
87
                        dump($destination);
88
                    }
89
                }
90
                unset($images[$key]);
91
            }
92
        }
93
94
        $this->repository->images = $images;
95
        $this->save();
96
    }
97
98
    /**
99
     * @param $filename