Code Duplication    Length = 19-23 lines in 2 locations

cloudcontrol/library/storage/JsonStorage.php 2 locations

@@ 623-645 (lines=23) @@
620
			}
621
		}
622
623
		public function deleteImageByName($filename)
624
		{
625
			$destinationPath = realpath(__DIR__ . '/../../www/images/');
626
627
			$images = $this->getImages();
628
629
			foreach ($images as $key => $image) {
630
				if ($image->file == $filename) {
631
					foreach ($image->set as $imageSetFilename) {
632
						$destination = $destinationPath . '/' . $imageSetFilename;
633
						if (file_exists($destination)) {
634
							unlink($destination);
635
						} else {
636
							dump($destination);
637
						}
638
					}
639
					unset($images[$key]);
640
				}
641
			}
642
643
			$this->repository->images = $images;
644
			$this->save();
645
		}
646
647
		/**
648
		 * @param $filename
@@ 758-776 (lines=19) @@
755
		 * @param $filename
756
		 * @throws \Exception
757
         */
758
		public function deleteFileByName($filename)
759
		{
760
			$destinationPath = realpath(__DIR__ . '/../../www/files/');
761
			$destination = $destinationPath . '/' . $filename;
762
763
			if (file_exists($destination)) {
764
				$files = $this->getFiles();
765
				foreach ($files as $key => $file) {
766
					if ($file->file == $filename) {
767
						unlink($destination);
768
						unset($files[$key]);
769
					}
770
				}
771
772
				$files = array_values($files);
773
				$this->repository->files = $files;
774
				$this->save();
775
			}
776
		}
777
778
		/*
779
		 *