Code Duplication    Length = 19-23 lines in 2 locations

cloudcontrol/library/storage/JsonStorage.php 2 locations

@@ 489-511 (lines=23) @@
486
			}
487
		}
488
489
		public function deleteImageByName($filename)
490
		{
491
			$destinationPath = realpath(__DIR__ . '/../../www/images/');
492
493
			$images = $this->getImages();
494
495
			foreach ($images as $key => $image) {
496
				if ($image->file == $filename) {
497
					foreach ($image->set as $imageSetFilename) {
498
						$destination = $destinationPath . '/' . $imageSetFilename;
499
						if (file_exists($destination)) {
500
							unlink($destination);
501
						} else {
502
							dump($destination);
503
						}
504
					}
505
					unset($images[$key]);
506
				}
507
			}
508
509
			$this->repository->images = $images;
510
			$this->save();
511
		}
512
513
		/**
514
		 * @param $filename
@@ 645-663 (lines=19) @@
642
		 *
643
		 * @throws \Exception
644
		 */
645
		public function deleteFileByName($filename)
646
		{
647
			$destinationPath = realpath(__DIR__ . '/../../www/files/');
648
			$destination = $destinationPath . '/' . $filename;
649
650
			if (file_exists($destination)) {
651
				$files = $this->getFiles();
652
				foreach ($files as $key => $file) {
653
					if ($file->file == $filename) {
654
						unlink($destination);
655
						unset($files[$key]);
656
					}
657
				}
658
659
				$files = array_values($files);
660
				$this->repository->files = $files;
661
				$this->save();
662
			}
663
		}
664
665
		/*
666
		 *