mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2025-10-13 16:34:23 -05:00
Filter and refactor
This commit is contained in:
@@ -25,17 +25,31 @@
|
||||
class D2TxtParser {
|
||||
|
||||
public $path = TXT_PATH;
|
||||
|
||||
// Files specific to Unique Items
|
||||
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
public function parseFile($file){
|
||||
return $this->toPHP($file);
|
||||
|
||||
}
|
||||
|
||||
function toPHP($file) {
|
||||
|
||||
public function parseFile($file) {
|
||||
if ($file == "Properties.txt") {
|
||||
return $this->filterProps($file);
|
||||
}
|
||||
return $this->parseData($file);
|
||||
}
|
||||
|
||||
function filterProps($file) {
|
||||
$data = $this->parseData($file);
|
||||
$propsToFilter = file(FILTER_PROPERTIES_FILE, FILE_IGNORE_NEW_LINES);
|
||||
foreach ($data as $d) {
|
||||
$allProps[] = $d['code'];
|
||||
}
|
||||
$filteredProps = array_diff($allProps, $propsToFilter);
|
||||
return $filteredProps;
|
||||
}
|
||||
|
||||
public function parseData($file) {
|
||||
$file = $this->path . $file;
|
||||
$rows = array_map(function ($v) {
|
||||
return str_getcsv($v, "\t");
|
||||
@@ -47,6 +61,6 @@ class D2TxtParser {
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user