Code Duplication    Length = 24-25 lines in 3 locations

application/models/Site_Model.php 3 locations

@@ 773-796 (lines=24) @@
770
		];
771
	}
772
773
	public function getTitleData(string $title_url, bool $firstGet = FALSE) {
774
		$titleData = [];
775
776
		$fullURL = $this->getFullTitleURL($title_url);
777
		$content = $this->get_content($fullURL);
778
779
		$data = $this->parseTitleDataDOM(
780
			$content,
781
			$title_url,
782
			"//h2[@class='aname']",
783
			"(//table[@id='listing']/tr)[last()]",
784
			"td[2]",
785
			"td[1]/a"
786
		);
787
		if($data) {
788
			$titleData['title'] = $data['nodes_title']->textContent;
789
790
			$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
791
792
			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
793
		}
794
795
		return (!empty($titleData) ? $titleData : NULL);
796
	}
797
}
798
799
class MangaStream extends Site_Model {
@@ 814-838 (lines=25) @@
811
		];
812
	}
813
814
	public function getTitleData(string $title_url, bool $firstGet = FALSE) {
815
		$titleData = [];
816
817
		$fullURL = $this->getFullTitleURL($title_url);
818
		$content = $this->get_content($fullURL);
819
820
		$data = $this->parseTitleDataDOM(
821
			$content,
822
			$title_url,
823
			"//div[contains(@class, 'content')]/div[1]/h1",
824
			"//div[contains(@class, 'content')]/div[1]/table/tr[2]",
825
			"td[2]",
826
			"td[1]/a",
827
			"<h1>Page Not Found</h1>"
828
		);
829
		if($data) {
830
			$titleData['title'] = $data['nodes_title']->textContent;
831
832
			$titleData['latest_chapter'] = preg_replace('/^.*\/(.*?\/[0-9]+)\/[0-9]+$/', '$1', (string) $data['nodes_chapter']->getAttribute('href'));
833
834
			$titleData['last_updated'] =  date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue));
835
		}
836
837
		return (!empty($titleData) ? $titleData : NULL);
838
	}
839
}
840
841
class WebToons extends Site_Model {
@@ 1092-1115 (lines=24) @@
1089
		];
1090
	}
1091
1092
	public function getTitleData(string $title_url, bool $firstGet = FALSE) {
1093
		$titleData = [];
1094
1095
		$fullURL = $this->getFullTitleURL($title_url);
1096
		$content = $this->get_content($fullURL);
1097
1098
		$data = $this->parseTitleDataDOM(
1099
			$content,
1100
			$title_url,
1101
			"//select[@name='manga']/option[@selected='selected']",
1102
			"//select[@name='chapter']/option[last()]",
1103
			"//html", //FIXME: EGScans doesn't have a proper title page so we can't grab chapter time.
1104
			"",
1105
			"Select a manga title to get started!"
1106
		);
1107
		if($data) {
1108
			$titleData['title'] = html_entity_decode($data['nodes_title']->textContent);
1109
1110
			$titleData['latest_chapter'] = (string) $data['nodes_chapter']->getAttribute('value');
1111
			$titleData['last_updated'] = date("Y-m-d H:i:s", now());
1112
		}
1113
1114
		return (!empty($titleData) ? $titleData : NULL);
1115
	}
1116
}
1117
1118
/*** FoolSlide sites ***/