name, 1 -> ISIN private array $dataIndex; public function takeData() : array { $needIndex = []; foreach ($this->getRawData() as $index => $rawDatum) { if ($index === 0) { $this->dataIndex = $rawDatum; foreach ($rawDatum as $i => $item) { if (!$item) { continue; } $keyName = DividendValues::searchForKeyName($item); if ($keyName) { $needIndex[$i] = $keyName; } } break; // continue; } // trigger_error(var_export($rawDatum,true)); } $ret = []; foreach ($this->getRawData() as $index => $datum) { if ($index === 0) { continue; } $row=[]; foreach ($datum as $i => $d) { if (isset($needIndex[$i])) { $row[$needIndex[$i]] = $d; } } if (count($row) < 1) { continue; } $tmpDate = intval($row['date']); $date = &$row['date']; if ($tmpDate > 2100) { $date = Date::excelToDateTimeObject($date); } else { $date = new \DateTime(str_replace(".", "-", $date)); } if (is_float($row['tax'])) { $row['tax'] = intval(round($row['tax']*100)); } $dividendObj = new DividendsData(); $dividendObj->setIsin($row['isin']); $dividendObj->setCurrency($row['currency']); $dividendObj->setTax(ClearTypes::clearInt($row['tax'])); $dividendObj->setCount(ClearTypes::clearInt($row['count'])); $dividendObj->setValue(ClearTypes::clearFloat($row['value'])); $dividendObj->setDateTime($date); $ret[] = $dividendObj; } return $ret; } public function takeColumnNames() : array { return $this->dataIndex; } private function getDataType($data,&$setDatas) : ?string { if (is_int($data)){ $ret = "count"; $count = &$setDatas['int']; if ($count===1){ $ret = "tax"; } if ($count > 1) { $ret = null; } $count++; return $ret; } if (is_float($data)) { $ret = "value"; $count = &$setDatas['float']; if ($count > 0) { $ret = null; } $count++; return $ret; } if (in_array(mb_substr((string) $data, 0, 2), ['CA', 'US', 'IE', 'GB']) && intval(mb_substr((string) $data, 2, 1))>0) { $count = &$setDatas['data']; $ret = "isin"; if ($count > 0) { $ret = null; } $count++; return $ret; } if (in_array($data, Currency::$currencies)) { return "currency"; } if (count(explode(".", (string) $data)) === 3 || count(explode("-", (string) $data)) === 3) { return "date"; } return null; } private function searchForDateIndex() : int { $ret = -1; foreach ($this->takeColumnNames() as $index => $takeColumnName) { if (str_contains((string) $takeColumnName,"DATE") || str_contains((string) $takeColumnName,"DATA")) { $ret = $index; break; } } return $ret; } }